You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trim() is executed to remove the items when length > max then itemCount is not reduced. Because of that cache.keys().length becomes more than max.
For example
var LRU = require("lru-cache");
var options = { max: 5 };
var cache = LRU(options);
cache.set("key1", "value1");
cache.set("key2", "value2");
cache.set("key3", "value3");
cache.set("key4", "value4");
cache.set("key5", "value5");
cache.set("key6", "value6");
cache.keys() now returns [ 'key6',
'key5',
'key4',
'key3',
'key2',
] and cache.keys().length returns 6
when you do add one more value to the cache like cache.set("key7", "value7"); then
cache.keys() returns
[ 'key7',
'key6',
'key5',
'key4',
'key3',
,
] and cache.keys().length returns 7.
I wonder whether this will lead to a memory leak when we add more items to the cache even if there is "max" property is set.
The text was updated successfully, but these errors were encountered:
When trim() is executed to remove the items when length > max then itemCount is not reduced. Because of that cache.keys().length becomes more than max.
For example
var LRU = require("lru-cache");
var options = { max: 5 };
var cache = LRU(options);
cache.set("key1", "value1");
cache.set("key2", "value2");
cache.set("key3", "value3");
cache.set("key4", "value4");
cache.set("key5", "value5");
cache.set("key6", "value6");
cache.keys() now returns [ 'key6',
'key5',
'key4',
'key3',
'key2',
] and cache.keys().length returns 6
when you do add one more value to the cache like cache.set("key7", "value7"); then
cache.keys() returns
[ 'key7',
'key6',
'key5',
'key4',
'key3',
,
] and cache.keys().length returns 7.
I wonder whether this will lead to a memory leak when we add more items to the cache even if there is "max" property is set.
The text was updated successfully, but these errors were encountered: