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

LRU Size growth #24

Closed
rohitjoshi opened this issue Dec 14, 2018 · 2 comments
Closed

LRU Size growth #24

rohitjoshi opened this issue Dec 14, 2018 · 2 comments

Comments

@rohitjoshi
Copy link
Contributor

I created a Lru instance with size of 1M and set 5M records. I was able to dump 4.9M+ keys using iterators.

  1. Does this implementation restrict the number of elements based on the initial size?
  2. Does iterator retrieve expired records as well?
  3. When we iterate over all key/val, what order does it return? MRU or LRU ?
@jeromefroe
Copy link
Owner

Hmm, it sounds like there may be some bug if the size of the cache is 1M but the iterator returned 4.9M records. Would you happen to be able to share the code to reproduce the bug so I can take a look myself? In regards to your other questions:

  1. Does this implementation restrict the number of elements based on the initial size?

Yes, if you specify a size for the cache in the constructor then it should never contain more than that many elements.

  1. Does iterator retrieve expired records as well?

No, expired records are dropped and so they are not available to be returned by the iterator.

  1. When we iterate over all key/val, what order does it return? MRU or LRU ?

The iteration is done in order from the most recently used element to the least recently used element.

@jeromefroe
Copy link
Owner

As @ssloboda noted in #29, he found and fixed a bug in pop that resulted in an item not being removed from the LRU's linked list although it was removed from the LRU's map. This would mean the item is invisible except when one gets an iterator over the LRU. It seems very likely that this is the same bug reported here. I released v0.1.13 which contains @ssloboda's fix. Since the bug description is the same, I'm going to close this issue but feel free to reopen it @rohitjoshi if you are still seeing the bug even in the new release.

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