php – UUID cassandra排序?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – UUID cassandra排序?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2442字,纯文字阅读大概需要4分钟。
内容图文
![php – UUID cassandra排序?](/upload/InfoBanner/zyjiaocheng/784/d18b4f69b8ab434b9e5fb97810cf15ad.jpg)
假设我有一个用户列系列,为特定客户端预设了唯一的键名
<?php
uniqid ("serverA");//generate something like; serverA4b3403665fea6
?>
我可以通过二级索引等选择它们:(生日例子来自phpcassa)
$column_family = new ColumnFamily($conn, 'Indexed1');
$index_exp = CassandraUtil::create_index_expression('birthdate', 1984);
$index_clause = CassandraUtil::create_index_clause(array($index_exp));
$rows = $column_family->get_indexed_slices($index_clause);
// returns an Iterator over:
// array('winston smith' => array('birthdate' => 1984))
foreach($rows as $key => $columns) {
// Do stuff with $key and $columns
Print_r($columns)
}
但是我只希望查询每页有30个最新添加的用户(创建的密钥)和多页面布局,每个页面显示较旧的密钥
我目前发现的唯一选择是使用来自phpcassa的uuid
uuid1()
generates a UUID based on the current time and the MAC
address of the machine.
- Pros: Useful if you want to be able to sort your UUIDs by creation time.
- Cons: Potential privacy leakage since it reveals which computer it was generated on and at what time.
- Collisions possible: If two UUIDs are generated at the exact same time (within 100 ns) on the same machine. (Or a few other unlikely
marginal cases.)
uuid2()
doesn’t seem to be used anymore.
uuid3()
generates a UUID by taking an MD5 hash of an arbitrary name
that you choose within some namespace (e.g. URL, domain name, etc).
- Pros: Provides a nice way of assigning blocks of UUIDs to different namespaces. Easy to reproduce the UUID from the name.
- Cons: If you have a unique name already, why do you need a UUID?
- Collisions possible: If you reuse a name within a namespace, or if there is a hash collision.
uuid4()
generates a completely random UUID.
- Pros: No privacy concerns. Don’t have to generate unique names.
- Cons: No structure to UUIDs.
- Collisions possible: If you use a bad random number generator, reuse a random seed, or are very, very unlucky.
uuid5()
is the same asuuid3()
, except using a SHA-1 hash instead
of MD5. Officially preferred overuuid3()
.
但这意味着我必须重写一些部分获得碰撞的可能性.
我有没有想到的智能黑客?
解决方法:
首先,关于UUID,如果您计划使用uuid1()或uuid4(),则不需要担心冲突(这些是唯一真正被使用的).这种事件的概率是天文数字低.别担心.
为了获得最近添加的30个密钥(以及分页功能),您真正在谈论时间序列数据.这是一个很好的intro to timeseries with Cassandra.您可以使用时间戳或v1 UUID作为列名称,使用唯一键作为列值.如果您选择将v1 UUID用于唯一键,则可以直接将它们放在列名中.那时你只是处理Cassandra中的正常时间序列数据和分页.
内容总结
以上是互联网集市为您收集整理的php – UUID cassandra排序?全部内容,希望文章能够帮你解决php – UUID cassandra排序?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。