batcache
batcache copied to clipboard
Functionality to flush the cache for a domain or any other batcache key
Flush keys can be used to change the cache key hash by adding an additional element to the $batcache->keys
array. This can be used to flush the cache for any key that can have duplicates, e.g. host
.
For example, one may want to invalidate the cache for a host/domain via mu-plugin on theme change.
Configuration:
- Requires a global object cache group.
- Add a key from
$batcache->keys
in$flush_keys
array. For example:
$flush_keys = array( 'host' );
Note: Adding a key in $flush_keys will invalidate the entire batcache cache.
- Call the flush method with args key and the value of that key. Example: If we want to flush the cache for a specific host/domain on theme change:
add_action ( 'switch_theme', function(){
global $batcache;
$batcache->flush( 'host', $_SERVER['HTTP_HOST'] );
} );