Registry /
storage / node-ts-cache-storage-ioredis
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));
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+)
fixSwitch 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
fixInstall the peer dependency: npm install node-ts-cache
Error: connect ECONNREFUSED 127.0.0.1:6379
Redis server not running or wrong host/port
fixEnsure Redis is running on the specified host and port, or update ioredis options.
Audit
Dependencies
node-ts-cacherequiredPeer dependency: core caching library that provides CacheContainer and @Cache decorator
ioredisrequiredPeer dependency: Redis client used by the storage adapter