We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
The ObjectCache class is intended to make it easy to reduce database calls and other resource-intensive operations.
use WordPress_ToolKit\ObjectCache; $cache = new ObjectCache( 'object_cache' => [ 'group' => 'my_plugin_cache', 'expire_hours' => 72 ] );
$my_option = $cache->get_object( 'cache_key_name', function() { return get_option( '_my_option_name' ); });
$my_option = $cache->get_object( 'carbon_field_name', function() { return carbon_get_theme_option( 'carbon_field_name' ); });
$cache->flush();
An easy way to test object caching locally is to install Local by FlyWheel (which loads sites in virtual machines and also includes Redis) and:
You can now enable/disable/flush the cache and test to make sure that everything is functioning as expected. Example:
var_dump( time() ); $time = $cache->get_object( 'php_time', function() { return time(); }); var_dump( $time );
There was an error while loading. Please reload this page.