pluginkollektiv / cachify

Smart but efficient cache solution for WordPress. Use DB, HDD, APC or Memcached for storing your blog pages. Make WordPress faster!
https://wordpress.org/plugins/cachify/
GNU General Public License v2.0
101 stars 32 forks source link

Database Cache: delete cache function doesn't work when object-cache (memcache etc.) is enabled #152

Open PixelbarEupen opened 6 years ago

PixelbarEupen commented 6 years ago

https://github.com/pluginkollektiv/cachify/blob/510a51088b2ec1bf7427b6d08abb12d323c86f73/inc/cachify_db.class.php#L102

The DB cache relies on transients that are automatically cached in the object cache (if enabled) like memcache(d), redis etc...

Your delete function makes a query for all transients to delete the afterwards. But when object-cache is enabled, no transients are stored in the database, so the cache won't be cleared.

This issue is explained here: https://css-tricks.com/the-deal-with-wordpress-transients/#article-header-id-23

So, wp_cache_flush(); would be the correct function, but it will delete the whole cache... not only the cachify-transients.

derweili commented 5 years ago

So as I understand, there are two options:

  1. We delete the whole object cache This will flush all data stored in the object cache from all plugins not only from cachify.

  2. We store a master transient which includes an array of all cached pages. This list of cached pages is later used to delete the cached files one by one. On large websites with several hundred pages this would be a lot of data stored in the master transient. I'm not sure if this is a good idea.

If it doesn't cause any more problems, variant 1 would be fine. Since transients mostly contain some kind of cache I wouldn't have a problem with the Cachify "flush cache" button flushing the cache of other plugins as well.