Filter
uncanny-automator
uap_options_cache_ttl
Filters the cache TTL for user access permissions data.
add_filter( 'uap_options_cache_ttl', $callback, 10, 1 );
Description
Filters the cache Time To Live (TTL) value for Automator options. Developers can modify this filter to control how long Automator options are cached, influencing performance and data freshness. The default TTL is defined by `self::CACHE_TTL`.
Usage
add_filter( 'uap_options_cache_ttl', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Increase the cache TTL for Automator Options to 1 hour (3600 seconds)
* for sites that might experience higher data volatility or require
* more up-to-date options.
*/
add_filter( 'uap_options_cache_ttl', 'my_custom_automator_options_cache_ttl', 10, 1 );
function my_custom_automator_options_cache_ttl( $default_ttl ) {
// Set the new TTL to 1 hour (3600 seconds)
$new_ttl = 3600;
// Optionally, you could add conditional logic here.
// For example, to only apply this to specific environments or sites.
// if ( defined( 'WP_ENVIRONMENT_TYPE' ) && 'production' === WP_ENVIRONMENT_TYPE ) {
// return $new_ttl;
// }
// Return the modified TTL.
return $new_ttl;
}
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/core/classes/automator-options/class-automator-options-cache.php:105
public function get_cache_ttl() {
return apply_filters( 'uap_options_cache_ttl', self::CACHE_TTL );
}