pmem / vmemcache

Buffer based LRU cache

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How is LRU policy implemented?

kmanikumar opened this issue · comments

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.

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.