snoop-sequence-id
v1.0.3
Published
This library addresses the issue of generating unique and exclusive IDs by storing the sequence digit in Redis or a .txt file
Downloads
7
Maintainers
Readme
SNOOP SEQUENCE ID
Reading time: 1 Min
Description: This library addresses the issue of generating unique and exclusive IDs by storing the sequence digit in Redis or a .txt file
INSTALL
Using npm:
npm install snoop-sequence-id
Example
import { SnoopSequence } from "snoop-sequence-id";
async function simulateRequest() {
//For bulk
const promise1 = SnoopSequence.bulkSequence(10, {
storeTo: 'redis',
// startSequence: 1, optional: beginning of the sequence
redisOptions: {
host: 'localhost',
port: 6379,
},
}); // with Redis
//For file
const promise2 = SnoopSequence.generate({
storeTo: 'file',
// startSequence:10, optional: beginning of the sequence
txtFilePath: 'sequence.txt',
}); //with File
const [r1, r2] = await Promise.all([promise1, promise2]);
console.log('Resultado 1:', r1);
console.log('Resultado 2:', r2);
}
simulateRequest();
Or
import {SnoopSequence} from "snoop-seuence-id";
const snoop = await SnoopSequence.generate({
storeTo: 'file',
// startSequence:10, optional: beginning of the sequence
txtFilePath: 'sequence.txt',
}).then(r => r)
console.log(snoop)
License
MIT