This code in ::put() implements the LRU, and as you can see, it uses the LRU data structure (i.e. simple list from most recently used to least):
while (bytes > max_bytes) { RamCacheLRUEntry *ee = lru.dequeue(); if (ee) remove(ee); else break; } On Sat, Dec 29, 2012 at 9:39 AM, Yunkai Zhang <yunkai...@gmail.com> wrote: > Hi folks: > > I'm reading code about RamCacheLRU, but I was confused by RamCacheLRU->lru > queue defined as following: > > struct RamCacheLRU: public RamCache { > ... > Que(RamCacheLRUEntry, lru_link) lru; > DList(RamCacheLRUEntry, hash_link) *bucket; > ... > }; > > By reading put/get/remove functions of RamCacheLRU class, it seems that > LRU algorithm was implemented by accessing *bucket* list instead of *lru* > queue. > > Do I understand it correctly? if so, we can remove lru queue and relative > code to speed up the put/get function of LRU a bit. > > -- > Yunkai Zhang > Work at Taobao >