Skip to content

Commit

Permalink
chore: updated package README
Browse files Browse the repository at this point in the history
  • Loading branch information
Tirke committed Aug 8, 2022
1 parent 123841f commit 5757ee1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-pumas-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tirke/node-cache-manager-ioredis': patch
---

updated package readme
50 changes: 44 additions & 6 deletions packages/node-cache-manager-ioredis/README.md
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')
```

0 comments on commit 5757ee1

Please sign in to comment.