maxSize is not correctly enforced
See original GitHub issueThe 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:
- Created 4 years ago
- Reactions:1
- Comments:13 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@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?