-
-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inserted items are evicted immediately if no maxSize
is set
#257
Comments
Yeah, that's a bug. Good catch. Should only skip saving entries bigger than maxEntrySize, not evict unless there's a maxSize set. On Nov 1, 2022, at 18:03, Daniel ***@***.***> wrote:
I'm not sure if this is intended, but it's definitely bizarre behavior given that this parameter is optional. See the following example:
const cache = LRU({
max: 500,
maxEntrySize: 75,
sizeCalculation: (_value, key) => key.length,
fetchMethod(key) {
return `${Math.random()}`
}
});
console.log(await cache.fetch('test')); // prints a random decimal
console.log(await cache.has('test')); // prints false
I think this while loop should only be run when maxSize is defined, and maxSize shouldn't default to 0.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
@isaacs thanks for confirming. I'll put up a PR to address in the next day or so. |
dkaps125
added a commit
to dkaps125/node-lru-cache
that referenced
this issue
Nov 2, 2022
isaacs
added a commit
that referenced
this issue
Nov 2, 2022
Thanks, fixed on 7.14.1 (took your commit, added a test and fixed a weird interaction with this and async fetching, where it was trying to calculate the length of background fetch promises). |
Awesome, thanks for closing this out so quickly! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure if this is intended, but it's definitely bizarre behavior given that this parameter is optional. See the following example:
I think this while loop should only be run when
maxSize
is defined, andmaxSize
shouldn't default to 0.The text was updated successfully, but these errors were encountered: