On Aug 3, 12:30 am, Peter <[email protected]> wrote: > Hi, I am new to memcached. I am wondering why expiration is necessary > for the protocol. Why do we want an item to be expired if there is > still space to keep it? Otherwise, we can still use some replacement > algorithm to replace it or garbage collection algorithm to collect it?
Sometimes, you don't control your source data production and can't perform cache transformations when things change. Sometimes, you really want something to go away after a certain amount of time because they're no longer relevant and you're best suited by recomputing. Sometimes, you just don't trust that every event will be processed correctly and having some part of your application be using incorrect data for 15 minutes or an hour or whatever is an acceptable worst case. Ideally, you're right -- all cache would be invalidated exactly when things change and nobody should ever use an expiration date on their caches. I have an application that does this, for everything else, there's TTL.
