How is LRU policy implemented?
kmanikumar opened this issue · comments
Kasi commented
Specifically- how does the LRU policy code make use of the ring buffer? I'm assuming doubly linked list is used to keep track of value access pattern.
Piotr Balcer commented
Here's the implementation: https://github.com/pmem/vmemcache/blob/master/src/vmemcache_repl.c
There's some lock-free magic needed to make this safe, but it basically boils down to buffering all doubly-linked list changes in the ring buffer, and then applying those changes (dequeue_all
) whenever the buffer is full or we try to operate on a list entry that has a queued change.