@tirke/node-cache-manager-ioredis
Advanced tools
Comparing version 2.0.1 to 2.1.0
# @tirke/node-cache-manager-ioredis | ||
## 2.1.0 | ||
### Minor Changes | ||
- [`91269b6`](https://github.com/Tirke/node-cache-manager-ioredis/commit/91269b6f8e7e79514f7732a89847e7ee270b9183) Thanks [@Tirke](https://github.com/Tirke)! - README example was not working because the root params where not passed to the created IORedis instance. | ||
This should now work. README now also contains intended ways to instantiate the cache-manager. | ||
## 2.0.1 | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "@tirke/node-cache-manager-ioredis", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"type": "commonjs", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/Tirke/node-cache-manager-ioredis", |
@@ -28,4 +28,6 @@ [![codecov](https://codecov.io/gh/Tirke/node-cache-manager-ioredis/branch/main/graph/badge.svg?token=8B6YUE99N3)](https://codecov.io/gh/Tirke/node-cache-manager-ioredis) | ||
### Using promises | ||
### Init | ||
I wanted to provide more type-safe ways to init the `cache-manager`. | ||
```typescript | ||
@@ -35,2 +37,51 @@ import { IoRedisStore, Store } from '@tirke/node-cache-manager-ioredis' | ||
// Default | ||
const defaultRedisCache = caching({ | ||
store: IoRedisStore, | ||
host: 'localhost', // default value | ||
port: 6379, // default value | ||
password: 'XXXXX', | ||
db: 0, | ||
ttl: 600, | ||
}) | ||
// With instanceConfig acceptingt type RedisOptions | ||
const instanceRedisCache = caching({ | ||
store: IoRedisStore, | ||
instanceConfig: { | ||
host: 'localhost', // default value | ||
port: 6379, // default value | ||
password: 'XXXXX', | ||
}, | ||
ttl: 600, | ||
}) | ||
// With clusterConfig acceptingt type ClusterConfig | ||
const clusterRedisCache = caching({ | ||
store: IoRedisStore, | ||
clusterConfig: { | ||
nodes: [ | ||
{ port: 6380, host: '127.0.0.1' }, | ||
{ port: 6381, host: '127.0.0.1' }, | ||
], | ||
}, | ||
ttl: 600, | ||
}) | ||
// Finaly passing a instiantiated IORedis instance type Redis | Cluster | ||
import Redis from 'ioredis' | ||
const instance = new Redis() | ||
const instantiatedRedisCache = caching({ | ||
store: IoRedisStore, | ||
redisInstance: instance, | ||
ttl: 600, | ||
}) | ||
``` | ||
### Generic usage with promises | ||
```typescript | ||
import { IoRedisStore, Store } from '@tirke/node-cache-manager-ioredis' | ||
import { caching } from 'cache-manager' | ||
const redisCache = caching({ | ||
@@ -37,0 +88,0 @@ store: IoRedisStore, |
@@ -29,3 +29,3 @@ /// <reference types="node" /> | ||
instanceConfig?: RedisOptions; | ||
}; | ||
} & RedisOptions; | ||
export declare type Store = RedisStore; | ||
@@ -32,0 +32,0 @@ declare type RedisValue = string | Buffer | number; |
@@ -114,3 +114,3 @@ "use strict"; | ||
if (!args.instanceConfig && !args.clusterConfig && !args.redisInstance) { | ||
this.client = new _ioredis.default(); | ||
this.client = new _ioredis.default(args); | ||
} | ||
@@ -117,0 +117,0 @@ } |
Sorry, the diff of this file is not supported yet
24360
106