node-cache icon indicating copy to clipboard operation
node-cache copied to clipboard

calling put with TTL value within Promise chain fails

Open rayjennings3rd opened this issue 7 years ago • 5 comments

Something like:

return new Promise((resolve, reject) => {
...
  cache.put(key, value, 90000);
  resolve(value);

});

Will not work unless the optional TTL is removed.

rayjennings3rd avatar Aug 22 '17 19:08 rayjennings3rd

👍

mfrye avatar Sep 15 '17 19:09 mfrye

just hit this bug myself and confirming that it's a problem :-(

fluxsauce avatar Oct 27 '17 19:10 fluxsauce

I believe memory-cache does not have this problem.

rayjennings3rd avatar Oct 27 '17 19:10 rayjennings3rd

@rayjennings3rd I found https://www.npmjs.com/package/node-cache and confirmed it worked properly.

Sorry to have to switch away, but this is a major blocker and it doesn't look like it's being addressed.

fluxsauce avatar Oct 30 '17 16:10 fluxsauce

@fluxsauce Yes, that is exactly what I switched to. Sorry, I got the names a bit mixed up. Memory-cache is this package (but it's git name is node-cache - Readme.md has it as memory-cache.) A bit confusing but the link you referenced: npm node-cache is exactly what I switch to a few weeks back and I can second confirmation that it works with a return new Promise() block. Glad you found it.

rayjennings3rd avatar Oct 30 '17 17:10 rayjennings3rd