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

If the cache timeout is sufficiently big, it doesn't work.

Open saltukalakus opened this issue 8 years ago • 3 comments

Set the timeout value to 999999999999, request the key back after 10 seconds and cache doesn't return the value. Observable in latest NPM version => 0.1.6

cache.put(key, value, 999999999999);

saltukalakus avatar Mar 10 '17 12:03 saltukalakus

In my Node.js test environment Number.MAX_SAFE_INTEGER returns 9007199254740991. Sufficiently bigger than 999999999999.

saltukalakus avatar Mar 10 '17 13:03 saltukalakus

Upon further investigation, this is because this library uses setTimeout to control the cache expiration. This means that the maximum value that can be passed in is 2147483647 (maximum positive 32 bit signed integer)

Source: https://nodejs.org/api/timers.html#timers_settimeout_callback_delay_args

michaelcacciatore avatar May 09 '17 15:05 michaelcacciatore

Correct, the library should probably throw if you pass a higher value than setTimeout can handle. Want to send a PR?

ptarjan avatar Jun 19 '17 06:06 ptarjan