I am using memcached with PHP trying for heavy caching to avoid db-reads. I am invalidating the cache on an update (application invalidates). But, stale cache data is becoming a big issue. Mostly, this is due to bug in invalidation (invalidates wrong key OR forgetting to invalidate the cache entry on an UPDATE).
Is there any good method to detect/debug these type of bugs during development/production?
The best thing to do is to put a wrapper function around mysql_query. Inside of that, just check if the query is an update or a delete to a cached table and parse out the keys that are being changed. This won't take long to write, is easy to test, and will prevent you from ever forgetting a cache invalidation again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With