Registry / database / persistent-programming-redis-state

persistent-programming-redis-state

JSON →
library3.0.88jsnpmunverified

A lightweight Redis-backed state management library for persistent programming. Version 3.0.88 provides a simple API to store, retrieve, and delete state objects in Redis, with support for expiration and serialization. It is designed for server-side applications needing durable session or workflow state. The package is actively maintained with frequent updates. Compared to alternatives, it offers minimal abstraction and direct Redis commands, making it suitable for projects already using Redis. Requires ioredis >=5 and is ESM-only since v3.

npm install persistent-programming-redis-state
INSTALL
IMPORT
SIG · PERSISTENT-PROGRAM
P
persistent-programming-redis-state
databasejavascriptv3.0.88
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 RedisState from 'persistent-programming-redis-state'
const RedisState = require('persistent-programming-redis-state')
Package is ESM-only since v3; CommonJS require will fail.
RedisState
import { RedisState } from 'persistent-programming-redis-state'
Named export available; use if you prefer destructuring.
createRedisState
import { createRedisState } from 'persistent-programming-redis-state'
Factory function for creating a state instance with custom Redis client.

Shows how to create a RedisState instance, set, get, and delete state objects.

import RedisState from 'persistent-programming-redis-state'; import Redis from 'ioredis'; const redis = new Redis({ host: 'localhost', port: 6379 }); const state = new RedisState(redis, { prefix: 'myapp:' }); async function main() { await state.set('user:123', { name: 'Alice', score: 100 }); const user = await state.get('user:123'); console.log(user); // { name: 'Alice', score: 100 } await state.delete('user:123'); redis.quit(); } main().catch(console.error);
Debug
Known issues
breakingPackage is ESM-only since v3. require() will throw ERR_REQUIRE_ESM.
fix
Use import syntax or dynamic import().
affects: >=3.0.0
deprecatedoptions.prefix is deprecated in v2; use options.namespace instead.
fix
Use options.namespace: 'myapp:'.
affects: >=2.0.0 <3.0.0
gotchaAll state keys are serialized using JSON.stringify. Objects with circular references will throw.
fix
Ensure values are JSON-serializable.
affects: all
gotchaExpiration is set in seconds; passing a Date object will result in NaN.
fix
Convert Date to seconds: Math.floor((date.getTime() - Date.now()) / 1000).
affects: all
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module not supported
Using CommonJS require() with ESM-only package.
fix
Use import or set { "type": "module" } in package.json.
TypeError: Converting circular structure to JSON
Attempting to store an object with circular reference.
fix
Remove circular references or use a replacer function.
RedisState is not a constructor
Using named import incorrectly when default import is expected.
fix
Use default import: import RedisState from 'persistent-programming-redis-state'.
Upgrade
Version history
3.0.88latest on npm
Audit
Dependencies
ioredisrequiredRedis client for Node.js
Agent activity
4 hits · last 30 days
node
4
Resources
persistent-programming-redis-state — npm install persistent-programming-redis-state · libregistry