Registry / database / redis-serial

redis-serial

JSON →
library1.0.0jsnpmunverified

Redis-serial is a lightweight Node.js library (v1.0.0) for generating unique serial numbers using Redis atomic operations. It leverages Redis INCR to produce sequential, unique, and persistent serial numbers across distributed systems. Key differentiator: simple API, no external dependencies beyond Redis, and built-in retry logic. Released as a stable package, though with low maintenance activity.

npm install redis-serial
INSTALL
IMPORT
SIG · REDIS-SERIAL
R
redis-serial
databasejavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import Serial from 'redis-serial'
✗ const Serial = require('redis-serial')
Package is ESM-only.
Serial
✓ import { Serial } from 'redis-serial'
✗ import Serial from 'redis-serial'
Named export available, but default export is preferred.
createClient
✓ import { createClient } from 'redis'
✗ import { createClient } from 'redis-serial'
createClient is from the redis package, not redis-serial.

This code creates a Redis client, initializes a Serial instance, and generates a new serial number, demonstrating basic usage.

import Serial from 'redis-serial'; import { createClient } from 'redis'; const client = createClient({ url: process.env.REDIS_URL || 'redis://localhost:6379' }); await client.connect(); const serial = new Serial({ client, key: 'myapp:serial' }); const id = await serial.generate(); // unique incrementing number console.log(id); // 1 client.quit();
Debug
Known issues
gotchaRedis connection must be established before creating a Serial instance.
fix
Ensure client.connect() resolves before new Serial({ client }).
affects: >=1.0.0
gotchaThe key must exist in Redis; if not, it will be created starting from 0.
fix
Initialize the key if needed, e.g., client.set('mykey', '0').
affects: >=1.0.0
breakingPackage is ESM-only; CommonJS require() will throw.
fix
Use 'type': 'module' in package.json or use dynamic import().
affects: >=1.0.0
Errors
Common errors & fixes
ERR wrong number of arguments for 'evalsha' command
Using unsupported Redis commands or misconfiguration.
fix
Check Redis version compatibility and ensure only INCR is used.
TypeError: Serial is not a constructor
Wrong import style; using default import incorrectly.
fix
Use import Serial from 'redis-serial' (default import).
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
redisrequiredUses Redis client for atomic INCR operations
Agent activity
7 hits · last 30 days
node
6
Resources
redis-serial — npm install redis-serial · libregistry