php - How to detect and debug stale cache entries? -


I am using a memcache with PHP for heavy caching to avoid db-reads. I am invalidating the cache on an update (invalid application), but stale cash data is becoming a big issue. Mostly, it is illegal due to a bug (invalidating incorrect key or forgetting to invalidate cache entry on an update).

Is there any good method for detecting / debugging these types of bugs during development / production?

The best part is to put a wrapper function around mysql_query. Inside that, check whether the query has been removed or deleted in the cached table and parsed the changed keys. It will not take much time to write, it is easy to test, and will prevent you from forgetting the cache's invalidation again.


Comments