IORedis store for node cache manager
This is a rewrite of dabroek/node-cache-manager-ioredis.
It uses TypeScript with updated dependencies and missing features added.
It aims to provide the most simple wrapper possible by just passing the configuration to the underlying ioredis
package.
Installation
npm install @tirke/cache-manager-ioredis
yarn add @tirke/cache-manager-ioredis
pnpm add @tirke/cache-manager-ioredis
Usage Examples
Using promises
import RedisStore, { Store } from '@tirke/cache-manager-ioredis'
import { caching } from 'cache-manager'
const redisCache = caching({
store: RedisStore,
host: 'localhost',
port: 6379,
password: 'XXXXX',
db: 0,
ttl: 600,
})
const cache = redisCache.store as Store
const redisClient = cache.getClient();
redisClient.on('error', (error: unknown) => {
console.log(error)
})
await redisCache.set('foo', 'bar', { ttl: 5 })
const result = await redisCache.get('foo')
await redisCache.del('foo')