Registry / database / o-redis

o-redis

JSON →
library1.0.33jsnpmunverified

o-redis is an automatic Redis cache update library that simplifies cache invalidation and synchronization. Version 1.0.33 is the latest stable release, with active development on GitHub. It provides a declarative API for defining cache dependencies and automatically updates caches when underlying data changes, reducing boilerplate. Unlike traditional caching libraries that require manual cache management, o-redis handles cache updates transparently, ideal for Node.js apps with Redis backends. Release cadence is irregular, focused on bug fixes and minor features.

npm install o-redis
INSTALL
IMPORT
SIG · O-REDIS
O
o-redis
databasejavascriptv1.0.33
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.

oRedis
import oRedis from 'o-redis'
const oRedis = require('o-redis')
Default ESM import; avoid CommonJS require unless using older Node versions.
CacheEntry
import { CacheEntry } from 'o-redis'
import { CacheEntry } from 'o-redis/cache-entry'
Named export for type checking; no subpath imports supported.
createCache
import { createCache } from 'o-redis'
Factory function to create a cached resource; requires redis client instance.

Connects to Redis, initializes o-redis, sets and retrieves a cached object with TTL of 3600 seconds.

import { createClient } from 'redis'; import oRedis from 'o-redis'; async function main() { const client = createClient(); await client.connect(); const cache = await oRedis(client, { prefix: 'myapp:' }); const key = 'user:123'; await cache.set(key, { name: 'Alice' }, 3600); const value = await cache.get(key); console.log(value); // { name: 'Alice' } await client.quit(); } main().catch(console.error);
Debug
Known issues
gotchaThe 'redis' client must be v4+; o-redis does not support legacy redis v3 callbacks.
fix
Use 'redis' v4.0.0 or later: npm install redis@latest
affects: >=1.0.0
breakingBefore v0.5.0, o-redis was named 'o-cache' with different API. Projects on older versions will break.
fix
Migrate to o-redis v1.x: replace package name and update imports.
affects: <0.5.0
deprecatedThe 'autoUpdate' method is deprecated in favor of 'cache.updateOnDependency'.
fix
Replace autoUpdate() calls with updateOnDependency().
affects: >=1.0.0 <1.1.0
gotchaCalling set() without TTL will default to infinite cache, which may cause memory issues.
fix
Always provide a TTL in seconds to set() for production use.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: client.connect is not a function
Using redis v3 client which does not have a connect() method.
fix
Update to redis v4+ and use client.connect() before passing to o-redis.
Error: Auto update failed: cannot read property 'pipeline' of undefined
o-redis internal pipeline fails if Redis client is not connected or provided correctly.
fix
Ensure Redis client is connected and passed to oRedis() as the first argument.
ERR wrong number of arguments for 'SET' command
Earlier versions had a bug where TTL was not serialized correctly in v1.0.0-1.0.10.
fix
Update to o-redis@1.0.11 or later: npm install o-redis@latest
Upgrade
Version history
1.0.33latest on npm
Audit
Dependencies
redisrequiredo-redis requires the Redis client to connect and interact with Redis server.
Agent activity
6 hits · last 30 days
node
6
Resources
o-redis — npm install o-redis · libregistry