sahilpaudel
Generate Timebased UUID in elixir
Hey there,
I am using Cassandra and it takes id as of type timebased uuid so I was curious if there is a way or library in Elixir that can generate Timebased UUID for me.
Thanks.
Most Liked
kokolegorille
ksuid is sortable uuid
jc00ke
I’ll throw ecto_ulid out there too. ULID is a pretty nice ID type (and while I realize this post is about IDs in Cassandra) but its lack of support in Postgres turned into a PITA. I was storing it as a :binary_id since it’s a 128bit integer but querying by the human-readable format was impossible; I had to convert it manually and that got old.
Anyway, here’s a good write-up of the differences between ULID & KSUID. Both are likely great options for your use case.
Qqwy
A cursory look through Xandra’s documentation and source code shows that Xandra does not (yet?) expose any way to generate timeuuid’s in Elixir (but only encoding/decoding values genereated from within Cassandra).
I did find another library called ‘Cassandra’ which has not seen very much usage and has not been updated in a couple of years, but it does contain an internal (undocumented) module called Cassandra.UUID which seems to generate UUIDs in the desired format.
Looking at that module in a bit more detail, it seems like the actual work is offloaded to elixir_uuid (which is stable and widely used), and that Cassandra’s timeuuids are nothing else than ‘v1’ UUIDs.
So using elixir_uuid is probably the best approach
.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








