uo_tincanny_reporting_disable_cache
Filters whether Tincanny reporting data is cached. Defaults to false, meaning caching is enabled.
add_filter( 'uo_tincanny_reporting_disable_cache', $callback, 10, 1 );
Description
This filter allows developers to disable Tincanny reporting cache. By returning `true` from the filter, you can prevent cached data from being retrieved, forcing a fresh data fetch on each request. Use this for debugging or when immediate data accuracy is critical, but be mindful of potential performance impacts.
Usage
add_filter( 'uo_tincanny_reporting_disable_cache', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
// Example of disabling the cache for Tincanny reporting under specific conditions.
// This filter allows developers to programmatically disable the cache if needed,
// for instance, during testing or when specific query parameters are present.
add_filter( 'uo_tincanny_reporting_disable_cache', 'my_custom_tincanny_cache_disable', 10, 1 );
function my_custom_tincanny_cache_disable( $disable_cache ) {
// Check if a specific URL parameter is set to disable cache.
// This could be useful for developers to bypass cache during debugging.
if ( isset( $_GET['disable_tincanny_cache'] ) && $_GET['disable_tincanny_cache'] === 'true' ) {
return true;
}
// You could add other conditions here, for example:
// if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) {
// return true; // Disable cache for administrators
// }
// Return the original value if no custom conditions are met.
return $disable_cache;
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/cache.php:33
public static function get( $key ) {
$cache_disabled_by_filter = apply_filters( 'uo_tincanny_reporting_disable_cache', false );
if ( true === $cache_disabled_by_filter ) {
return array();
}
if ( 'cached' !== get_option( 'tincanny_user_report_report_mode' ) ) {
return array();
}
if ( isset( $_GET['group_id'] ) ) {
$key .= '_' . $_GET['group_id'];
} else {
$key .= '_all';
}
return wp_cache_get( $key, 'tincanny-reporting' );
}