folly
folly copied to clipboard
EvictingCacheMap - promotion on insertion when key already exists
When inserting a new element into the EvictingCacheMap. i.e. auto [it, inserted] = cache.insert(key, value);, if the key already exists in the map, then inserted == false.
However, the act of inserting does not promote the element that was accessed, and so a subsequent call to find() needs to be made to promote the element stored at key.
It would be preferable if there was a way to either promote with only access to the iterator it, OR to have an input parameter (i.e. promote = true) to insert() that allows an existing element in the map to be promoted during the function call.