rhubarbgroup / redis-cache

A persistent object cache backend for WordPress powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.
https://wordpress.org/plugins/redis-cache/
GNU General Public License v3.0
427 stars 149 forks source link

Flush cache for particular post #430

Closed pawmanaloto closed 1 year ago

pawmanaloto commented 1 year ago

How do I flush the cache for particular post on save? I know I can use the save_post hook but is there a way to also remove the post meta and relation cache that comes with the post?

A5hleyRich commented 1 year ago

WordPress handles cache flushing internally. You do not need to manually flush the object cache unless you're saving/updating posts in a non-standard way, for example, if you're not using the WordPress built-in functions https://developer.wordpress.org/reference/functions/wp_update_post/

tillkruss commented 1 year ago

@pawmanaloto There is also clean_post_cache()

https://developer.wordpress.org/reference/functions/clean_post_cache/