@tirke/node-cache-manager-ioredis
Advanced tools
Comparing version 1.0.0 to 1.0.1
# @tirke/node-cache-manager-ioredis | ||
## 1.0.1 | ||
### Patch Changes | ||
- [`5757ee1`](https://github.com/Tirke/node-cache-manager-ioredis/commit/5757ee1785520207e946e8f2d134bc4048dd7240) Thanks [@Tirke](https://github.com/Tirke)! - updated package readme | ||
## 1.0.0 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@tirke/node-cache-manager-ioredis", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"type": "commonjs", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/Tirke/node-cache-manager-ioredis", |
@@ -1,11 +0,49 @@ | ||
# node-cache-manager-ioredis | ||
# IORedis store for node cache manager | ||
This library was generated with [Nx](https://nx.dev). | ||
This is a rewrite of [dabroek/node-cache-manager-ioredis](https://github.com/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`](https://github.com/luin/ioredis) package. | ||
## Building | ||
Installation | ||
------------ | ||
Run `nx build node-cache-manager-ioredis` to build the library. | ||
```sh | ||
npm install @tirke/cache-manager-ioredis | ||
``` | ||
```sh | ||
yarn add @tirke/cache-manager-ioredis | ||
``` | ||
```sh | ||
pnpm add @tirke/cache-manager-ioredis | ||
``` | ||
## Running unit tests | ||
Usage Examples | ||
-------------- | ||
Run `nx test node-cache-manager-ioredis` to execute the unit tests via [Jest](https://jestjs.io). | ||
### Using promises | ||
```typescript | ||
import RedisStore, { Store } from '@tirke/cache-manager-ioredis' | ||
import { caching } from 'cache-manager' | ||
const redisCache = caching({ | ||
store: RedisStore, | ||
host: 'localhost', // default value | ||
port: 6379, // default value | ||
password: 'XXXXX', | ||
db: 0, | ||
ttl: 600, | ||
}) | ||
// listen for redis connection error event | ||
const cache = redisCache.store as Store | ||
const redisClient = cache.getClient(); | ||
redisClient.on('error', (error: unknown) => { | ||
// handle error here | ||
console.log(error) | ||
}) | ||
await redisCache.set('foo', 'bar', { ttl: 5 }) | ||
const result = await redisCache.get('foo') | ||
await redisCache.del('foo') | ||
``` |
21030
50