-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Koa 2 #27
Comments
Hi there! I've solved it like this, and it seems to be working. const cash = require('koa-cash');
const convert = require('koa-convert');
const LRU = require('lru-cache');
const cache = LRU(1000);
app.use(convert(cash({
get: key => cache.get(key),
set: (key, value) => cache.set(key, value)
})));
app.use(async (ctx, next) => {
const cashed = await ctx.cashed();
if (cashed) return;
await next();
}); |
@lbeschastny I created a version with Koa 2 support: https://github.com/joukosaastamoinen/cash/tree/koa-2-support If there was a branch for the |
@joukosaastamoinen I've created a I've also published it under Now all I need is a confirmation that it works fine with |
@lbeschastny I just took it into use in a small production app with Koa 2, and seems to work fine. I confirmed that responses are actually cached. |
Did we bin support for Koa 2? |
This library doesn't have a @next tag? Only generators?
Also would be nice if the examples were a bit more clear. I can't still manage to get it working and documentation is not so friendly.
I think this works now with lru-cache because their API is like:
The text was updated successfully, but these errors were encountered: