Int64 UUID (UInt64, UInt63) autoincremented via redis-server¶ ↑
Generates universally unique identifiers (UUID64) with unsigned Int64 (so it will be UInt63) for use in distributed applications. Based on: 1) possibility autoincrement value in redis-server 2) unix timestamps with microseconds 3) expire key possibility in redis database.
Generating UInt63 Ids¶ ↑
Call #generate to generate a new UUID64. The method returns a Int64 unique value.
For example in rails:
before_create do |record| record.id ||= RedisInt64Autoincrement.generate(Rails.cache.redis || Redis.new(url: "redis://localhost:6379/0")) end
Why so hard?¶ ↑
We have an issue where the servers have different times on each server and during the time the server syncs the time we have a shift of a few seconds. So this lib have +-50(UUID64_MAX_SECONDS_EXPIRE) seconds maximum for delta shift.
Latest and Greatest¶ ↑
Source code and documentation hosted on Github: github.com/trumenov/redis_int64_autoincrement
To get UUID64 from source:
git clone git://github.com/trumenov/redis_int64_autoincrement.git
License¶ ↑
This package is licensed under the MIT license and/or the Creative Commons Attribution-ShareAlike.
:include: MIT-LICENSE