shard-uuid
v1.0.0
Published
UUID generator for database shards
Downloads
20
Readme
ShardUUID
Compact 64-bit UUID generator for database logical shards.
Each UUID consists of:
- 32 bits for time in seconds (gives 136 years of IDs from start of epoch 2017-01-01 00:00:00);
- 22 bits that represent the logical shard ID;
- 10 bits that represent an auto-incrementing sequence (modulus 1024).
Installation
$ npm install --save shard-uuid
Usage
const shardUUID = require('shard-uuid');
shardUUID.getUUID(65536, 1023, false).then((uuid) => {
console.log(uuid);
}).catch((err) => {});