pmem / CacheLib

Pluggable in-process caching engine to build and scale high performance services
https://www.cachelib.org
Apache License 2.0
5 stars 13 forks source link

Fix moveRegularItemOnEviction function #36

Closed vinser52 closed 1 year ago

vinser52 commented 2 years ago

@igchor Please review


This change is Reviewable

vinser52 commented 2 years ago

In this PR I have fixed the moveRegularItemOnEviction function. The fix contains the following:

  1. Fixed the comment of the function which describes the return value of moveRegularItemOnEviction function. The function tries to move the content of the oldItem to the newItemHdl in order to recycle the oldItem. If the function succeeds it returns the handle to the oldItem, so that it can be reused for the new stuff. Otherwise, it returns an empty handle.
  2. If replaceInMMContainer(oldItemPtr, *newItemHdl) or newItemHdl->isAccessible() return false it means some concurrent thread removed this key or called inserOrReplace, but we still can recycle the oldItem.
  3. Removed code block related to chainedItem from moveRegularItemOnEviction because this function intended to work only with regular Items and we have no logic for chainedItem yet.