koa-cache
koa-cache is a koa middleware which provide cache for app.
Install
npm install koa-cache-it
Usage
var app = require('koa')();var cache = require('koa-cache-it');app.use(cache({store:redisStore(),prefix:"koa-cache-test:"}));app.use(function * controller(){this.cache.get('cache-key',function * provider(){// do somethingreturn "your value";});});
APIs
- get(key[,function *(){}])
- set(key,value)
- destory(key)