Does memcached guarantee persistent IN-MEMORY storage of objects for as long as it is running and the available configured memory space enough ?
An example is storage of session data for messaging systems. Under what circumstances will i try to read a key from memcached ( which i wrote in earlier, with no timeouts for the data against that key) and get an empty response ? what is the behavior of memcached when configured memory is exceeded (will it swap out some data, and which data will it swap out) ?

- 7,736
- 3
- 47
- 86
3 Answers
I had faced this problem and you wont be able to predict which data will be removed. The data being swapped out dependes on the size of the new data you are going to cache and on the slab and chunk sizes in the memcached memory.

- 4,777
- 4
- 24
- 41
memcached will never guarantee it will return something you stored in it. As a cache, it only guarantees it won't return data you've not told it is valid (or told it that it's invalid).

- 89,080
- 21
- 111
- 133
Important Points to Remember Memcached has no internal mechanism to track misses which may happen. When the size of cache is full, older data is removed in LFU order. So clients must treat Memcached just as a transitory cache; they cannot assume that data stored in Memcached is always there. Memcached does not support any clustering features. It is important to implement Serialization of Data Structures that an application intends to cache in memcached. When an object stored in cache is no longer valid from business perspective, application must make sure to manually remove it from Cache. For example if application is storing product information in cache then in case of a product becomes no longer available it needs to be manually removed from cache.