mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Implmented cache group clearing in Memcache engine
This commit is contained in:
parent
d0f7842f36
commit
6f9d2c01db
2 changed files with 28 additions and 1 deletions
|
@ -262,7 +262,13 @@ class MemcacheEngine extends CacheEngine {
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments the group value to simulate deletion of all keys under a group
|
||||
* old values will remain in sotrage until they expire.
|
||||
*
|
||||
* @return boolean success
|
||||
**/
|
||||
public function clearGroup($group) {
|
||||
|
||||
return (bool) $this->_Memcache->increment($group);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -451,4 +451,25 @@ class MemcacheEngineTest extends CakeTestCase {
|
|||
|
||||
$this->assertFalse(Cache::read('test_groups', 'memcache_groups'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test clearing a cache group
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
public function testGroupClear() {
|
||||
Cache::config('memcache_groups', array(
|
||||
'engine' => 'Memcache',
|
||||
'duration' => 3600,
|
||||
'groups' => array('group_a', 'group_b')
|
||||
));
|
||||
|
||||
$this->assertTrue(Cache::write('test_groups', 'value', 'memcache_groups'));
|
||||
$this->assertTrue(Cache::clearGroup('group_a', 'memcache_groups'));
|
||||
$this->assertFalse(Cache::read('test_groups', 'memcache_groups'));
|
||||
|
||||
$this->assertTrue(Cache::write('test_groups', 'value2', 'memcache_groups'));
|
||||
$this->assertTrue(Cache::clearGroup('group_b', 'memcache_groups'));
|
||||
$this->assertFalse(Cache::read('test_groups', 'memcache_groups'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue