trafficserver-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Plevyak <jplev...@acm.org>
Subject Re: Question about RamCacheLRU
Date Sat, 29 Dec 2012 17:57:03 GMT
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.me@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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message