You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
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
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.The text was updated successfully, but these errors were encountered: