简体   繁体   English

如何压缩uuid和timeuuid?

[英]how to compress uuid and timeuuid?

uuid or Universally unique identifier and timeuuid are long 128-bit value. uuid或通用唯一标识符和timeuuid是长的128位值。

In Cassandra database and because of its concepts I used uuid and timeuuid for our entities identifier and now I want to compress uuid and timeuuid or reduce its size when client (user) can see the id in the URL bar. 在Cassandra数据库中,由于其概念,我使用uuidtimeuuid作为我们的实体标识符,现在当客户端(用户)可以在URL栏中看到ID时,我想压缩uuidtimeuuid或减小其大小。

For example Twitter also used Cassandra but when you open a Tweet, the Tweet's id is like 10153967535312713 but a simple uuid is like 10646334-2c02-11e6-bb4a-7720eb141b83 that is more characters and not user friendly (of course both IDs are not user friendly :D) 例如,Twitter还使用了Cassandra,但是当您打开Tweet时,该Tweet的ID类似于10153967535312713而一个简单的uuid就像10646334-2c02-11e6-bb4a-7720eb141b83那样,它的字符更多且不友好(当然这两个ID都不是user友好的:D)

In different programming languages there are some compression functions, such as gzcompress in PHP and GZIPOutputStream in Java but these functions (classes) will compress data and return in GZIP format which is not allowed to use in URL! 在不同的编程语言中,有一些压缩函数,例如PHP中的gzcompress和Java中的GZIPOutputStream ,但是这些函数(类)将压缩数据并以GZIP格式返回,不允许在URL中使用!

Now just by the way is there any way or function/algorithm to get smaller or compressed version of a uuid or timeuuid? 现在,顺便问一下,是否有任何方法或函数/算法来获得较小的或压缩的uuid或timeuuid版本?

Twitter originally developed Snowflake a long time ago and I believe that it is this id that Twitter is still using. Twitter最初是很久以前开发的Snowflake ,我相信Twitter仍在使用此id。 There are now many flake id implementations available that can generate a UUID like number instead of a true UUID. 现在有许多可用的薄片ID实现 ,它们可以生成像数字一样的UUID,而不是真正的UUID。 I have used Flake Java in a project of mine. 我在我的项目中使用过Flake Java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM