On Jun 4, 1:34 am, dormando <[email protected]> wrote: > 'If there are no free chunks, and no free pages in the appropriate slab > class, memcached will look at the end of the LRU for an item to "reclaim". > It will search the last few items in the tail for one which has already > been expired, and is thus free for reuse.' > > So no, not random, but it tries to walk up the tail a little to find > something expired if the very bottom isn't expire.
Should probably also note that the LRU isn't *exact*, so you shouldn't ever feel like you know for sure exactly what will be evicted. Three things may spare the exact recently-used item from the chopping block: 1. Items in transit are not eligible for eviction. 2. There's a separate LRU list by size (won't help us to free an 80 byte object to store a 128k incoming thing). 3. The LRU isn't adjusted on *every* request (we'd rather it be fast than doing constant memory writes to be 100% LRUiffic). So, to repeat myself slightly: It's an LRU, but mostly it's a cache. If you think you're positive you always know what will be there, you'll probably be sad someday, and it will be in the middle of a bunch of other stuff and you won't have time to deal with it well.
