문제

(First of all, my English is not very good, please)

As we know, memcached provides lazy expiration, and "replaces" LRU data in its slabs, however I'm not very clear how it does this. For example, if a slab is full, but some data in this slab are expired, what will happen when data are added to the slab?

  1. Does memcached find some expired data and replace them with the added data, or
  2. does it replace the LRU data, or
  3. does it do something else?

As far as I know, the lazy expiration is such that memcached is not actively removing expired data from each slab, but instead only removing expired entries when the key of the expired entry is referenced. This is a waste of resources, isn't it?

도움이 되었습니까?

해결책

When an item is requested (a get request) Memcached checks the expiration time to see if the item is still valid before returning it to the client.

Similarly when adding a new item to the cache, if the cache is full, it will look at for expired items to replace before replacing the least used items in the cache.

So expired items are only purged when a get request is sent for the expired item or the expired item is cleared because the storage is needed.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top