ZF-11813: Zend_Cache_Backend_TwoLevels -> auto_refresh_fast_cache causes problems with cleaning by tag(s)

Description

The default for "auto_refresh_fast_cache" option in the TwoLevels Cache is true. Imho this is a bad idea as it causes problems when the flushing by tags is used. In my scenario the fast backend is memcached and the slow backend is file (but should be the same with all other backend combinations).

Let's assume the cache timeout is one hour. Let's further assume the website has at least some requests every couple of minues. With the "auto_refresh_fast_cache" option all hit cache items in the fast cache get their lifetime extended (endlessly, unless there is no cache hit for one hour). To the contrary the corresponding slow cache item expires after one hour. If there is a cleaning done by tags (e.g.: Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG) then the item in memcache will not be removed as expired items geet ignored:


if (time() > $metadatas['expire']) {
    continue;
}

So we end up with a not deleted, not deletable (by tags) zombie item in memcache.

I don't see any good reason for the "auto_refresh_fast_cache" option to be true but in any case there should be a warning in the documentation (and also in the Class file) that this will cause problems when cleaning by tags is used! Imho the default should also be changed to "false" for this option.

Best regards, Anton

Comments

Any reason why this fix: http://framework.zend.com/issues/browse/ZF-11524 hast not made it into 1.11.11 (or before), by the way?

This bit us real hard, please merge the above fix as it turns into a major headache in an impossible-to-reproduce way.