Object Cache Pro

Customizations

Dashboard widget

By default the dashboard widget is visible to all users with the rediscache_manage capability. In some scenarios you might want to hide the dashboard widget, or restrict access to certain roles.

/**
* Remove the Object Cache Pro dashboard widget.
*/

add_action( 'wp_dashboard_setup', function () {
remove_meta_box( 'dashboard_objectcache', 'dashboard', 'normal' );
}, 20 );

Automatic flushing

By default the object cache will be flushed whenever the drop-in is enabled or disabled, as well as when the plugin is deactivated. This helps prevent avoid stale cache data and potential data loss and fatal errors. You can alter this behavior using the objectcache_autoflush filter.

/**
* Disable automatic object cache flushes.
*/

add_filter( 'objectcache_autoflush', '__return_false' );

Automatic drop-in updates

By default the object cache drop-in will be kept up-to-date, unless DISALLOW_FILE_MODS is set to true. You can alter this behavior using the file_mod_allowed filter.

/**
* Disable automatic object cache drop-in updates.
*/

add_filter( 'file_mod_allowed', function ( $file_mod_allowed, $context ) {
if ( $context === 'object_cache_dropin' ) {
return false;
}

return $file_mod_allowed;
}, 10, 2 );

Drop-in validation

In some rare scenarios you might wish to disable the drop-in validation or drop-in version check. You can do so with the objectcache_validate_dropin and objectcache_validate_dropin_version filters.

/**
* Force the object cache drop-in to be valid.
*/

add_filter( 'objectcache_validate_dropin', '__return_false' );

/**
* Force object cache drop-in version to be up-to-date.
*/

add_filter( 'objectcache_validate_dropin_version', '__return_false' );

Filesystem health check

One of the plugin’s health checks tests for filesystem access to ensure the object-cache.php drop-in can be seamlessly updated.

This health check temporarily creates a .object-cache-test.tmp file in WP_CONTENT_DIR. To disable this health check you can use the objectcache_check_filesystem filter.

/**
* Disable filesystem health check.
*/

add_filter( 'objectcache_check_filesystem', '__return_false' );