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.

maxSize is not correctly enforced

See original GitHub issue

The implementation of this LRU cache does not enforce the documented behavior:

maxSize
Required
Type: number

The maximum number of items before evicting the least recently used items.

Running this code snippet produces true in the console:

const m = new QuickLRU({
    maxSize: 2
});
m.set("key1", "value1");
m.set("key2", "value2");
m.set("key3", "value3");
console.log(m.has("key1"));

The cache should only be able to store 2 items and when adding a total of 3 items to the list, the first key-value pair (key1-value1) should be evicted. However, from the result of executing the code, you can see that key1 is still in the cache.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
BTOdellcommented, Oct 25, 2019

It might be “expected behavior” if you’ve read the code and know that it’s going to behave that way. General users of this NPM package should only have to read the public documentation to understand what the package will do for them. If the implementation fails to produce the documented behavior then the implementation is bugged and should be fixed.

1reaction
adityapatadiacommented, Jul 4, 2020

@BTOdell it would be great if you can share your Map based LRU cache implementation. May be we can take inspiration and fix this one?

Read more comments on GitHub >

github_iconTop Results From Across the Web

String field max size is not being enforced - ServiceNow
My client is not happy that these fields are not displaying correctly. Does anyone have a fix for this problem, or know if...
Read more >
PM86337: AUTHCACHE SIZES DO NOT SPECIFY A VALID RANGE
The maxSize and minSize properties of the authCache element are specified as type Integer, but do not specify any range. The correct range...
Read more >
How to set the max size of upload file - Stack Overflow
MaxFileSize: The maximum size allowed for uploaded files, in bytes. If the size of any ... So the above answers are almost correct...
Read more >
StorageMaximumLevel vs Set-SPSite -MaxSize - TechNet - Microsoft
When I used the latter format, the quota seems to be enforced, but does not show up in the central admin UI (_admin/sitequota.aspx)....
Read more >
[SERVER-12998] Can upsert document over 16MB - MongoDB Jira
... limits so it can send oversized docs to the server. The server was not patched so limits should be enforced. They are...
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