query-monitor icon indicating copy to clipboard operation
query-monitor copied to clipboard

Track cache add, edit and delete

Open spacedmonkey opened this issue 2 years ago • 4 comments

Add a panel that tracks the wp_cache_add, wp_cache_delete and wp_cache_set function calls. This would have to be an opt in feature.

spacedmonkey avatar Apr 22 '22 11:04 spacedmonkey

This would be very useful, unfortunately there aren't any hooks in core to track this. Need to get some actions added to core, but also bear in mind the fact that these functions are pluggable by caching plugins.

johnbillion avatar Apr 22 '22 13:04 johnbillion

Couldn't we just detect if there is already an object cache file. If there is no object cache enabled, override the memory cache object file with our own. This override, could have the hooks / filters that we need to do the requested. This is simple to how database case is overridden. Does that make sense?

spacedmonkey avatar Apr 22 '22 14:04 spacedmonkey

We could do yeah but I think that affects the state of wp_using_ext_object_cache(). Would need to do some juggling there I think.

johnbillion avatar Apr 22 '22 15:04 johnbillion

wp_using_ext_object_cache can be called and set to false, is that is a problem.

We could also just extend the WP_Object_Cache class and override $GLOBALS['wp_object_cache']. That would also work. Similar to this.

https://github.com/johnbillion/query-monitor/blob/ff52a9573e9aa465c2faf47a682c88f6070f2b97/wp-content/db.php#L157

spacedmonkey avatar Apr 22 '22 15:04 spacedmonkey