I am wanting to generate smaller (integer) numbers using Cassandra.
The usage will likely be generating fewer than 1000 Ids/day, but definitely needs to be non-conflicting, and would prefer minimal chance of waste (unused blocks of numbers).
I've considered the following option(s)
read+update
until I get a successful result.I'm also using UUIDs for records on creation, I'm only wanting to use the sequential numbers for records that are publicly published, and will be part of a URL.
The update operation is atomic, however you don't get the updated value back as an output from the operation. Update
/Select
combination is definitely not atomic. Any other process can increment/decrement counter value in between of your update
and select
calls, therefore making your results unpredictable. Here is a good description of how counters work: http://www.datastax.com/dev/blog/whats-new-in-cassandra-2-1-a-better-implementation-of-counters. Try to use some synchronization layer in front of Cassandra to accomplish atomicity of this operation. Astyanax is one of the examples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With