function MemCacheClearCase::clearWildcardPrefixTest in Memcache API and Integration 6
Same name and namespace in other branches
- 7 tests/memcache.test \MemCacheClearCase::clearWildcardPrefixTest()
- 7 tests/memcache6.test \MemCacheClearCase::clearWildcardPrefixTest()
Test cache clears using wildcard prefixes.
2 calls to MemCacheClearCase::clearWildcardPrefixTest()
- MemCacheClearCase::testClearWildcardLifetime in tests/
memcache.test - Test clearing using wildcard prefix, with cache lifetime.
- MemCacheClearCase::testClearWildcardNoLifetime in tests/
memcache.test - Test clearing using wildcard prefixes, no cache lifetime.
File
- tests/
memcache.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.');
}