Skip to content

maxSize is not correctly enforced #17

Open
@BTOdell

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions