evheniy / koa-2-ioredis

Koa 2 middleware for working with ioredis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Koa.js 2 ioredis middleware

ioredis midleware for koa 2 application

NPM

npm version Build Status Coverage Status Linux Build Windows Build

Dependency Status devDependency Status NSP Status

License GitHub stars GitHub forks GitHub issues Twitter

How to install

npm i -S koa-2-ioredis

How to use

Config

config/default.json

{
  "redis": {
    "host": "127.0.0.1",
    "port": 6379
  }
}

Middleware

app.js:

const Koa = require('koa');
const app = new Koa();
const ioredis = require('koa-2-ioredis');

app.use(ioredis());

app.use(async (ctx, next) => {

    await ctx.redis.set(key, value);
    const data = await ctx.redis.get(key);
    
});

In module

const redis = require('koa-2-ioredis/redis');

redis.set('test', 'test');

Debug

DEBUG=koa2:ioredis npm start

Links

About

Koa 2 middleware for working with ioredis

License:MIT License


Languages

Language:JavaScript 100.0%