-
Hi all ! As part of a research project, I'm building a LRU-based cache using cachelib. One key need for this project is to be able to manage cache evictions. In particular, I would like to be able to trigger eviction when needed. According to the documentation on MMContainers, I see that I can use methods like For instance, I first thought of doing something like Am I missing something? Is there any way to get the eviction iterator as a cachelib user, through a public method? Please note that in my case, I can't just iterate over the elements contained in the cache. I would like to leverage the LRU eviction mechanism to retrieve the last-recently-used item. Thanks a lot in advance for any help. If something is not clear, feel free to ask me any precisions. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
No. CacheLib does not have a (public) mechanism for users to trigger eviction. In theory, you only need an eviction when you are doing an allocation, and cachelib does that for you when you call cachelib.allocate(). Do you mind specifying what exactly you are trying to achieve? For example, do you have a slightly modified LRU algorithm you want to use in place of cachelib's MMLru's implementation? |
Beta Was this translation helpful? Give feedback.
If you want to control what exactly to evict, you can extend the existing MMLru or replace it with your own implementation.
However, depending on what you mean by cache size, it may or maynot work for your purpose. Evicting an item does not free the memory space back to the operating system. If your goal is to free up space to the OS, you can do it via memory monitor: https://cachelib.org/docs/Cache_Library_User_Guides/oom_protection.
Similarly you can modify or use your own implementation there.