This is a library generating unique id in short pattern.
- Generate a 64-bit encoded uuid in Ruby with length of 22.
- Generate a 16-bit encoded BSON object_id.
- Generate a 64-bit encoded BSON object_id with length of 16.
gem install uuid64
gem 'uuid64'
require 'uuid64'
puts SecureRandom.uuid64 # "Ymu4xVZrRP29PPnixxwoPg"
puts SecureRandom.mongo_id # "57320baec9de9a14d2000000"
puts SecureRandom.mongo_id64 # "VzILtMnemhTSAAAD"
- object_id and object_id64 may conflict when running on same process, multiple threads.