Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/namshi/node-redis-wrapper
https://github.com/namshi/node-redis-wrapper
Last synced: 24 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/namshi/node-redis-wrapper
- Owner: namshi
- Created: 2017-04-16T09:21:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-13T07:22:28.000Z (about 7 years ago)
- Last Synced: 2024-04-24T20:15:29.331Z (7 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 5
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# node-redis-wrapper
A small, promise-based, pooled wrapper for the `redis` module:
we re-use the same code across a bunch of modules, hence this
abstraction.## Usage
Given a confg object such as:
```
host: redis
port: 6379
pool:
max: 20
min: 2
acquireTimeoutMillis: 3000
```You can then start using redis with:
``` js
const redis = require('node-redis-wrapper')(config)redis.del('some-key').then(...).catch(...)
// or with async/await
await redis.del('some-key')
```## Custom constructor
If you want to control how the redis client is created (eg. to use [redis-sentinel](https://www.npmjs.com/package/redis-sentinel) & the likes), you can just specify a `createClient` function in the config:
``` js
let config = {...}config.createClient = function() {
require('redis-sentinel').createClient(...options...)
}const redis = require('node-redis-wrapper')(config)
```