cbstats output with memcache bucket
maybe somebody will be so kind to clarify a point for me.
Reading around, I seem to understand that expired items should be removed from a bucket *only* on two occasions... in the words of a post in the forums:
- when an expired item is accessed (if your application is doing a get of a key that is expired it will return a not found/null and remove the item from the RAM)
- when the bucket has no RAM left it will automatically remove some expired items to be able to store new items."
Ok. But then, how do I read the cbstats items snippet below? What does the 'reclaimed' figure means? The bucket has plenty of memory left (2.5G free out of 6G total).
What I find strange is that the number of items in this bucket oscillates between 5 and 6 M, with a weekly cycle. But if we are not evicting anything (stats zero everywhere) and each deletion due to expiration is followed by a new item being inserted (receive a miss -> fetch the item from a database and re-insert it in cache) , then why is the number of items decreasing? Shouldn't this be constant or always increasing?
When you store an item into the memcached bucket types it first tries to look at the least recently used objects to see if it is already expired. If that is the case it will grab that object instead of allocating new memory. This will cause the reclaimed counter to increase. If none of the objects in the tail of that list have expired it will try to allocate more memory for the item, but if we've already used all of the memory we're supposed to use it will go back to the tail of the list of the objects and evict one of the objects instead (and that cause the eviction counter to increase).
Hope this helps.