Skip to content
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

New2Q with size = 1 fails to create the cache #51

Open
mkeeler opened this issue Oct 17, 2018 · 1 comment
Open

New2Q with size = 1 fails to create the cache #51

mkeeler opened this issue Oct 17, 2018 · 1 comment

Comments

@mkeeler
Copy link
Member

mkeeler commented Oct 17, 2018

This seems to be due to calculating the frequent and recent LRU sizes and being truncated to 0. So when those get created the following error is returned:

"Must provide a positive size"

Obviously this is really edge casey as who would want a cache of size 1 (except I did when implementing some unit tests for Consul).

rsjethani added a commit to rsjethani/golang-lru that referenced this issue Sep 1, 2019
For cases where the combination of 2Q size and ghostRatio result in
evict cache of size 0, the error message displayed to the user is
rather confusing.

This commit proposes to fix the code and give a suitable error message
to the user.

Addresses: Issue hashicorp#51
@rsjethani
Copy link

@mkeeler you are right this is an edge case. However the code is not wrong when it denies creation of a size 1 2Q cache. A size 1 2Q cache makes no sense.

But yes the code should give proper error message instead of the current confusing one. So here is a small change I have made via PR #60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants