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

Put a new item that has already been at the front of the cache #1

Open
chungphb opened this issue Apr 23, 2021 · 1 comment
Open

Put a new item that has already been at the front of the cache #1

chungphb opened this issue Apr 23, 2021 · 1 comment
Labels
cache Related to cache

Comments

@chungphb
Copy link
Owner

chungphb commented Apr 23, 2021

To prevent putting a new item that has already been at the front of the cache, check key == _items.front().first && value == _items.front().second before adding the new item and removing the old one.

@chungphb
Copy link
Owner Author

chungphb commented Apr 23, 2021

It can be applied to all items to be fair. (Instead of removing the old item, just move it to the front of the cache).

It all comes down to whether adding the new item and removing the old one are faster or slower / safer or riskier then checking the new item and moving the old one to the front of the cache.

@chungphb chungphb changed the title [cache][put] Put a new item that has already been at the front of the cache Put a new item that has already been at the front of the cache May 3, 2021
@chungphb chungphb added the cache Related to cache label May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cache Related to cache
Projects
None yet
Development

No branches or pull requests

1 participant