Clearing cached plugin data if it is using an external object cache

We note that the Transients API uses the Object Cache API, when we use an object-cache.php drop-in file.

For example if wp_using_ext_object_cache() returns true, then

get_transient( $transient ) 
-> wp_cache_get( $transient, 'transient' )

set_transient( $transient, $value, $expiration ) 
-> wp_cache_set( $transient, $value, 'transient', $expiration )

delete_transient( $transient ) 
-> wp_cache_delete( $transient, 'transient' )

where the group is transient.

The Object Cache API doesn’t support wp_cache_delete_group() to delete cache by a group and it currently has a wontfix in ticket #4476.

The reason given there was that not all persistent cache solutions supports it. But there are some ways described in the ticket, that depend on the cache solution.

As an example, the WP Redis persistent object cache implementation supports wp_cache_delete_group(), but not the Memcached Object Cache implementation.

If we use transients in our plugin, with persistent object cache, then we should note that if we used:

if( function_exists( 'wp_cache_delete_group' ) )
{
    wp_cache_delete_group( 'transient' );
}

then it looks like we would flush all the transients, not just the ones set in our own plugin.

If the cache keys are known beforehand, then we could delete those with:

wp_cache_delete( $cachekey, $cachegroup );

where $cachegroup is 'transient' if we used transients.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)