{"id":46160,"library":"redis-serial","title":"redis-serial","description":"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.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"github.com/vizorvr/redis-serial","tags":["javascript","redis","serial","number"],"install":[{"cmd":"npm install redis-serial","lang":"bash","label":"npm"},{"cmd":"yarn add redis-serial","lang":"bash","label":"yarn"},{"cmd":"pnpm add redis-serial","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Uses Redis client for atomic INCR operations","package":"redis","optional":false}],"imports":[{"note":"Package is ESM-only.","wrong":"const Serial = require('redis-serial')","symbol":"default","correct":"import Serial from 'redis-serial'"},{"note":"Named export available, but default export is preferred.","wrong":"import Serial from 'redis-serial'","symbol":"Serial","correct":"import { Serial } from 'redis-serial'"},{"note":"createClient is from the redis package, not redis-serial.","wrong":"import { createClient } from 'redis-serial'","symbol":"createClient","correct":"import { createClient } from 'redis'"}],"quickstart":{"code":"import Serial from 'redis-serial';\nimport { createClient } from 'redis';\n\nconst client = createClient({ url: process.env.REDIS_URL || 'redis://localhost:6379' });\nawait client.connect();\n\nconst serial = new Serial({ client, key: 'myapp:serial' });\nconst id = await serial.generate(); // unique incrementing number\nconsole.log(id); // 1\nclient.quit();","lang":"typescript","description":"This code creates a Redis client, initializes a Serial instance, and generates a new serial number, demonstrating basic usage."},"warnings":[{"fix":"Ensure client.connect() resolves before new Serial({ client }).","message":"Redis connection must be established before creating a Serial instance.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Initialize the key if needed, e.g., client.set('mykey', '0').","message":"The key must exist in Redis; if not, it will be created starting from 0.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use 'type': 'module' in package.json or use dynamic import().","message":"Package is ESM-only; CommonJS require() will throw.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'across':34 'activ':61 'api':40 'atom':20 'beyond':44 'built':48 'built-in':47 'depend':43 'differenti':38 'distribut':35 'extern':42 'generat':14 'incr':25 'javascript':62 'key':37 'leverag':23 'librari':11 'lightweight':9 'logic':51 'low':59 'mainten':60 'node.js':10 'number':17,33,65 'oper':21 'packag':56 'persist':31 'produc':27 'redi':2,5,19,24,45,63 'redis-seri':1,4 'releas':52 'retri':50 'sequenti':28 'serial':3,6,16,32,64 'simpl':39 'stabl':55 'system':36 'though':57 'uniqu':15,29 'use':18 'v1.0.0':12","created_at":"2026-06-07T12:58:34.802110+00:00","updated_at":"2026-06-07T12:58:34.802110+00:00","problems":[{"fix":"Check Redis version compatibility and ensure only INCR is used.","cause":"Using unsupported Redis commands or misconfiguration.","error":"ERR wrong number of arguments for 'evalsha' command"},{"fix":"Use import Serial from 'redis-serial' (default import).","cause":"Wrong import style; using default import incorrectly.","error":"TypeError: Serial is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/vizorvr/redis-serial","github":"github.com/vizorvr/redis-serial","docs":null,"changelog":null,"pypi":null,"npm":"redis-serial","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}