Exemplo n.º 1
0
/**
 * Removes cache contents for a given group.
 *
 * @codeCoverageIgnore
 *
 * @param  string $group  The cache group.
 * @param  string $suffix The suffix. Optional.
 *
 * @return bool
 */
function xu_cache_delete_group($group, $suffix = '')
{
    if (!function_exists('wp_cache_delete_group')) {
        return false;
    }
    return wp_cache_delete_group(xu_cache_key($group, $suffix));
}
Exemplo n.º 2
0
 public function test_wp_cache_delete_group()
 {
     $key1 = rand_str();
     $val1 = rand_str();
     $key2 = rand_str();
     $val2 = rand_str();
     $key3 = rand_str();
     $val3 = rand_str();
     $group = 'foo';
     $group2 = 'bar';
     if (!defined('WP_REDIS_USE_CACHE_GROUPS') || !WP_REDIS_USE_CACHE_GROUPS) {
         $GLOBALS['wp_object_cache']->add_redis_hash_groups(array($group, $group2));
     }
     // Set up the values
     wp_cache_set($key1, $val1, $group);
     wp_cache_set($key2, $val2, $group);
     wp_cache_set($key3, $val3, $group2);
     $this->assertEquals($val1, wp_cache_get($key1, $group));
     $this->assertEquals($val2, wp_cache_get($key2, $group));
     $this->assertEquals($val3, wp_cache_get($key3, $group2));
     $this->assertTrue(wp_cache_delete_group($group));
     $this->assertFalse(wp_cache_get($key1, $group));
     $this->assertFalse(wp_cache_get($key2, $group));
     $this->assertEquals($val3, wp_cache_get($key3, $group2));
     // _call_redis( 'delete' ) always returns true when Redis isn't available
     if (class_exists('Redis')) {
         $this->assertFalse(wp_cache_delete_group($group));
     } else {
         $this->assertTrue(wp_cache_delete_group($group));
     }
 }