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

keys() writes checks that get() can't cash

Open haphut opened this issue 8 years ago • 0 comments

I'd like to do something like this:

const values = cache.keys().map((key) => cache.get(key));

Based on the documentation, I expect:

  • that values does not contain any nulls if I had not inserted any into cache,
  • that cache does not delete elements while timers do not have a chance to run and
  • that a function named get does not delete elements.

Currently memory-cache deletes elements both with timers and as a side-effect within get among other methods. I think it would be helpful to write such design decisions high up in the README. The API description of get in the README does not explain this behavior. The uncertainty in the result of del is the only hint about side-effects.

haphut avatar Nov 07 '17 10:11 haphut