Skip to content

Commit

Permalink
Merge pull request #419 from mirus-ua/ioredis-doc-update
Browse files Browse the repository at this point in the history
(doc) Update ioredis README.md
  • Loading branch information
Tirke authored Oct 31, 2023
2 parents d3ef6e0 + 29a7910 commit 632c22e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/node-cache-manager-ioredis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,26 @@ await redisCache.set('foo', 'bar', { ttl: 5 })
const result = await redisCache.get('foo')
await redisCache.del('foo')
```

### Flush all DBs
```typescript
import { ioRedisStore, RedisCache } from '@tirke/node-cache-manager-ioredis'
import { caching } from 'cache-manager'

const redisCache: RedisCache = caching(ioRedisStore, {
host: 'localhost', // default value
port: 6379, // default value
password: 'XXXXX',
ttl: 600,
})

// listen for redis connection error event
const cache = redisCache.store
cache.client.on('error', (error: unknown) => {
// handle error here
console.log(error)
})

// it uses `flushall` under the hood, so it drops all DBs
await redisCache.reset()
```

0 comments on commit 632c22e

Please sign in to comment.