Registry / storage / node-ts-cache-storage-ioredis

node-ts-cache-storage-ioredis

JSON →
library4.4.0jsnpmunverified

Redis storage adapter for node-ts-cache using ioredis. Current version 4.4.0. Requires ioredis and node-ts-cache as peer dependencies. The adapter accepts an ioredis instance, not a client name or options object. No breaking changes reported since v1, but requires ESM imports in modern Node.js and TypeScript projects.

npm install node-ts-cache-storage-ioredis
INSTALL
IMPORT
SIG · NODE-TS-CACHE-STOR
N
node-ts-cache-storage-ioredis
storagejavascriptv4.4.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.

IoRedisStorage
import { IoRedisStorage } from 'node-ts-cache-storage-ioredis'
import IoRedisStorage from 'node-ts-cache-storage-ioredis'
Named export, not default. ESM-only; no CommonJS support.
Cache
import { Cache } from 'node-ts-cache'
import { Cache } from 'node-ts-cache-storage-ioredis'
Cache decorator comes from node-ts-cache, not the storage package.
CacheContainer
import { CacheContainer } from 'node-ts-cache'
const { CacheContainer } = require('node-ts-cache')
CJS require() works but is not recommended for TypeScript projects.

Creates an ioredis client, wraps it in IoRedisStorage, attaches to CacheContainer, and uses @Cache decorator on a method.

import { Cache, CacheContainer } from 'node-ts-cache'; import { IoRedisStorage } from 'node-ts-cache-storage-ioredis'; import IoRedis from 'ioredis'; const redis = new IoRedis({ port: 6379, host: '127.0.0.1', family: 4, password: process.env.REDIS_PASSWORD ?? '', db: 0 }); const userCache = new CacheContainer(new IoRedisStorage(redis)); class UserService { @Cache(userCache, { ttl: 60 }) async getUsers(): Promise<string[]> { return ['Alice', 'Bob']; } } const service = new UserService(); service.getUsers().then(users => console.log(users));
Debug
Known issues
gotchaIoRedisStorage requires an instance of ioredis, not redis or other Redis clients. Passing a different client type will fail silently or throw connection errors.
fix
Use only ioredis to create the Redis connection.
affects: >=1.0.0
deprecatedThe library is ESM-only from version 4.x onwards. CommonJS require() may not work or may require dynamic import().
fix
Use import syntax or dynamic import() in CommonJS projects.
affects: >=4.0.0
gotchaThe 'password' option in ioredis constructor is ignored if the Redis server does not require authentication. Setting it unnecessarily can cause warnings but not errors.
fix
Omit password if not required, or use environment variable to conditionally set it.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Class extends value #<Object> is not a constructor or null
Using CJS require() with ESM-only package (node-ts-cache-storage-ioredis v4+)
fix
Switch to import syntax or use dynamic import: const { IoRedisStorage } = await import('node-ts-cache-storage-ioredis');
Error: Cannot find module 'node-ts-cache'
Missing peer dependency node-ts-cache
fix
Install the peer dependency: npm install node-ts-cache
Error: connect ECONNREFUSED 127.0.0.1:6379
Redis server not running or wrong host/port
fix
Ensure Redis is running on the specified host and port, or update ioredis options.
Upgrade
Version history
4.4.0latest on npm
Audit
Dependencies
node-ts-cacherequiredPeer dependency: core caching library that provides CacheContainer and @Cache decorator
ioredisrequiredPeer dependency: Redis client used by the storage adapter
Agent activity
20 hits · last 30 days
node
20
Resources
node-ts-cache-storage-ioredis — npm install node-ts-cache-storage-ioredis · libregistry