-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@tirke/node-cache-manager-ioredis': patch | ||
--- | ||
|
||
updated package readme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,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') | ||
``` |