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

Simplifies logic of LRUDiskCache #527

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

danzanzini
Copy link

What is the purpose of this pull request?

This PR changes the LRUDiskCache implementations to use the dispose function of the LRU implementation to clear the disk cache instead of implementing it on get and set functions.

What problem is this solving?

After adding some LRUDiskCache to our code, we saw that its metrics were not working correctly. By checking the implementation, I suspect that when any key needs to be removed from the cache, none of the keys will be retrieved due to this logic. The key to be deleted is not being verified before removal.

How should this be manually tested?

I think the only way to test this properly is installing it in some accounts and check the behavior.

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Requires change to documentation, which has been updated accordingly.

@danzanzini danzanzini requested a review from filipewl June 6, 2023 19:48
@@ -59,18 +57,10 @@ export class LRUDiskCache<V> implements CacheLayer<string, V>{
public get = async (key: string): Promise<V | void> => {
const timeOfDeath = this.lruStorage.get(key)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confused when I read this. The items stored in the cache are timestamps?
🤔

Copy link
Author

@danzanzini danzanzini Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! It took me a while to understand it, too. I'm still unsure if we should keep this behavior, but I don't want to change many things simultaneously.

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

Successfully merging this pull request may close these issues.

2 participants