function ApcCacheClearCase::testClearArray in APC - Alternative PHP Cache 7
Test clearing using an array.
File
- tests/
apc.test, line 296
Class
- ApcCacheClearCase
- Test cache clearing methods.
Code
function testClearArray() {
// Create three cache entries.
cache_set('test_cid_clear1', $this->default_value, $this->default_bin);
cache_set('test_cid_clear2', $this->default_value, $this->default_bin);
cache_set('test_cid_clear3', $this->default_value, $this->default_bin);
$this
->assertTrue($this
->checkCacheExists('test_cid_clear1', $this->default_value) && $this
->checkCacheExists('test_cid_clear2', $this->default_value) && $this
->checkCacheExists('test_cid_clear3', $this->default_value), t('Three cache entries were created.'));
// Clear two entries using an array.
cache_clear_all(array(
'test_cid_clear1',
'test_cid_clear2',
), $this->default_bin);
$this
->assertFalse($this
->checkCacheExists('test_cid_clear1', $this->default_value) || $this
->checkCacheExists('test_cid_clear2', $this->default_value), t('Two cache entries removed after clearing with an array.'));
$this
->assertTrue($this
->checkCacheExists('test_cid_clear3', $this->default_value), t('Entry was not cleared from the cache'));
// Set the cache clear threshold to 2 to confirm that the full bin is cleared
// when the threshold is exceeded.
variable_set('cache_clear_threshold', 2);
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 cache entries were created.'));
cache_clear_all(array(
'test_cid_clear1',
'test_cid_clear2',
'test_cid_clear3',
), $this->default_bin);
$this
->assertFalse($this
->checkCacheExists('test_cid_clear1', $this->default_value) || $this
->checkCacheExists('test_cid_clear2', $this->default_value) || $this
->checkCacheExists('test_cid_clear3', $this->default_value), t('All cache entries removed when the array exceeded the cache clear threshold.'));
}