You are here

function MemCacheClearCase::clearWildcardPrefixTest in Zircon Profile 8

Same name in this branch
  1. 8 modules/memcache/tests/memcache.test \MemCacheClearCase::clearWildcardPrefixTest()
  2. 8 modules/memcache/tests/memcache6.test \MemCacheClearCase::clearWildcardPrefixTest()
Same name and namespace in other branches
  1. 8.0 modules/memcache/tests/memcache.test \MemCacheClearCase::clearWildcardPrefixTest()
  2. 8.0 modules/memcache/tests/memcache6.test \MemCacheClearCase::clearWildcardPrefixTest()

Test cache clears using wildcard prefixes.

4 calls to MemCacheClearCase::clearWildcardPrefixTest()
MemCacheClearCase::testClearWildcardLifetime in modules/memcache/tests/memcache.test
Test clearing using wildcard prefix, with cache lifetime.
MemCacheClearCase::testClearWildcardLifetime in modules/memcache/tests/memcache6.test
Test clearing using wildcard prefix, with cache lifetime.
MemCacheClearCase::testClearWildcardNoLifetime in modules/memcache/tests/memcache.test
Test clearing using wildcard prefixes, no cache lifetime.
MemCacheClearCase::testClearWildcardNoLifetime in modules/memcache/tests/memcache6.test
Test clearing using wildcard prefixes, no cache lifetime.

File

modules/memcache/tests/memcache6.test, line 319

Class

MemCacheClearCase
Test cache clearing methods.

Code

function clearWildcardPrefixTest() {
  variable_set("cache_flush_{$this->default_bin}", 0);
  cache_set('test_cid_clear1', $this->default_value, $this->default_bin);
  cache_set('test_cid_clear2', $this->default_value, $this->default_bin);
  $this
    ->assertTrue($this
    ->checkCacheExists('test_cid_clear1', $this->default_value) && $this
    ->checkCacheExists('test_cid_clear2', $this->default_value), t('Two caches were created for checking cid substring with wildcard true.'));
  cache_clear_all('test_', $this->default_bin, TRUE);
  $this
    ->assertFalse($this
    ->checkCacheExists('test_cid_clear1', $this->default_value) || $this
    ->checkCacheExists('test_cid_clear2', $this->default_value), t('Two caches removed after clearing cid substring with wildcard true.'));

  // Test for the case where a wildcard object disappears, for example a
  // partial memcache restart or eviction.
  cache_set('test_cid_clear1', $this->default_value, $this->default_bin);
  $this
    ->assertTrue($this
    ->checkCacheExists('test_cid_clear1', $this->default_value), 'The cache was created successfully.');
  cache_clear_all('test_', $this->default_bin, TRUE);
  $this
    ->assertFalse($this
    ->checkCacheExists('test_cid_clear1', $this->default_value), 'The cache was cleared successfully.');

  // Delete the wildcard manually to simulate an eviction.
  $wildcard = '.wildcard-' . 'test_';
  dmemcache_delete($wildcard, $this->default_bin);

  // Reset the memcache_wildcards() static cache.
  memcache_wildcards(FALSE, FALSE, FALSE, TRUE);
  $this
    ->assertFalse($this
    ->checkCacheExists('test_cid_clear1', $this->default_value), 'The cache was cleared successfully.');
}