Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nswbmw/koa-redis-pool
Redis middleware for koa, support connection pool.
https://github.com/nswbmw/koa-redis-pool
Last synced: about 2 months ago
JSON representation
Redis middleware for koa, support connection pool.
- Host: GitHub
- URL: https://github.com/nswbmw/koa-redis-pool
- Owner: nswbmw
- Created: 2014-11-10T05:56:49.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-03T14:26:09.000Z (almost 9 years ago)
- Last Synced: 2024-08-04T00:04:33.879Z (5 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 19
- Watchers: 12
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- awesome-koa - koa-redis-pool - Redis中间件,支持连接池。 ![](https://img.shields.io/github/stars/MangroveTech/koa-redis-pool.svg?style=social&label=Star) ![](https://img.shields.io/npm/dm/koa-redis-pool.svg?style=flat-square) (仓库 / 中间件)
README
## koa-redis-pool
koa-redis-pool is a redis middleware for koa, support connection pool.
### Install
npm i koa-redis-pool --save
### Usage
```
app.use(redisPool({
host: 'localhost',
port: 6379,
max: 100,
min: 1,
timeout: 30000,
log: false,
db: 0,
... // https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options
}));
```or
```
app.use(redisPool({
url: 'localhost:6379', // if exist, ignore `host`, `port`, `password` and `db`.
...
}));
```or
```
app.use(redisPool('localhost:6379'));
```### Example
```
'use strict';var koa = require('koa');
var redisPool = require('./');var app = koa();
app.use(redisPool());
app.use(function* (next) {
yield this.redis.set('name', 'nswbmw');
yield* next;
this.body = yield this.redis.get('name');
});app.listen(3000);
```### License
MIT