javaphpcassandrauuidtimeuuid

how to compress uuid and timeuuid?


uuid or Universally unique identifier and timeuuid are long 128-bit value.

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.

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)

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!

Now just by the way is there any way or function/algorithm to get smaller or compressed version of a uuid or timeuuid?


Solution

  • Twitter originally developed Snowflake a long time ago and I believe that it is this id that Twitter is still using. There are now many flake id implementations available that can generate a UUID like number instead of a true UUID. I have used Flake Java in a project of mine.