|
|
@@ -70,6 +70,8 @@ class MemcacheEngineTest extends CakeTestCase {
|
|
|
public function tearDown() {
|
|
|
Configure::write('Cache.disable', $this->_cacheDisable);
|
|
|
Cache::drop('memcache');
|
|
|
+ Cache::drop('memcache_groups');
|
|
|
+ Cache::drop('memcache_helper');
|
|
|
Cache::config('default');
|
|
|
}
|
|
|
|
|
|
@@ -400,4 +402,35 @@ class MemcacheEngineTest extends CakeTestCase {
|
|
|
$memcache->write('key', $value, 50 * DAY);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Tests that configuring groups for stored keys return the correct values when read/written
|
|
|
+ * Shows that altering the group value is equivalent to deleting all keys under the same
|
|
|
+ * group
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGroupReadWrite() {
|
|
|
+ Cache::config('memcache_groups', array(
|
|
|
+ 'engine' => 'Memcache',
|
|
|
+ 'duration' => 3600,
|
|
|
+ 'groups' => array('group_a', 'group_b')
|
|
|
+ ));
|
|
|
+ Cache::config('memcache_helper', array(
|
|
|
+ 'engine' => 'Memcache',
|
|
|
+ 'duration' => 3600,
|
|
|
+ 'prefix' => ''
|
|
|
+ ));
|
|
|
+ $this->assertTrue(Cache::write('test_groups', 'value', 'memcache_groups'));
|
|
|
+ $this->assertEquals('value', Cache::read('test_groups', 'memcache_groups'));
|
|
|
+
|
|
|
+ Cache::increment('group_a', 1, 'memcache_helper');
|
|
|
+ $this->assertFalse(Cache::read('test_groups', 'memcache_groups'));
|
|
|
+ $this->assertTrue(Cache::write('test_groups', 'value2', 'memcache_groups'));
|
|
|
+ $this->assertEquals('value2', Cache::read('test_groups', 'memcache_groups'));
|
|
|
+
|
|
|
+ Cache::increment('group_b', 1, 'memcache_helper');
|
|
|
+ $this->assertFalse(Cache::read('test_groups', 'memcache_groups'));
|
|
|
+ $this->assertTrue(Cache::write('test_groups', 'value3', 'memcache_groups'));
|
|
|
+ $this->assertEquals('value3', Cache::read('test_groups', 'memcache_groups'));
|
|
|
+ }
|
|
|
}
|