question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:

set(key, value, maxAge)
get(key) => value

Both of these will update the “recently used”-ness of the key. They do what you think. maxAge is optional and overrides the cache maxAge option if provided.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
joukosaastamoinencommented, Feb 7, 2017

@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 next version, I could create a pull request.

2reactions
stepankuzmincommented, Dec 9, 2016

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();
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Koa - next generation web framework for node.js
Introduction. Koa is a new web framework designed by the team behind Express, which aims to be a smaller, more expressive, and more...
Read more >
Contact KOA | KOA FAQ | Frequently Asked Questions
Contact the KOA Corporate Office. Contact Us Online. Customer Service: 1-888-562-0000. Please note: KOA Campgrounds are franchised and handle all of the day ......
Read more >
Support for KOA 2 #2572 - nestjs/nest - GitHub
Feature Request Support for KOA 2 Is your feature request related to a problem? Please describe. NO Describe the solution you'd like Support...
Read more >
Building A Server-Side Application With Async Functions and ...
First, I'll recap what async functions are and how they work. Then, I'll highlight the differences between Koa 1 and Koa 2. After...
Read more >
koa-2-acl - npm
Koa 2 Access Control Lists (koa-2-acl) enable you to manage the requests made to your koa server. It makes use of ACL rules...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found