diff --git a/lib/Cake/Cache/Engine/ApcEngine.php b/lib/Cake/Cache/Engine/ApcEngine.php index b816b9f21da..37cfde2014f 100644 --- a/lib/Cake/Cache/Engine/ApcEngine.php +++ b/lib/Cake/Cache/Engine/ApcEngine.php @@ -110,7 +110,7 @@ public function delete($key) { * * @param boolean $check If true, nothing will be cleared, as entries are removed * from APC as they expired. This flag is really only used by FileEngine. - * @return boolean True if the cache was successfully cleared, false otherwise + * @return boolean True Returns true. */ public function clear($check) { if ($check) { diff --git a/lib/Cake/Cache/Engine/WincacheEngine.php b/lib/Cake/Cache/Engine/WincacheEngine.php index 702aa21a779..46ef6def25f 100644 --- a/lib/Cake/Cache/Engine/WincacheEngine.php +++ b/lib/Cake/Cache/Engine/WincacheEngine.php @@ -112,13 +112,27 @@ public function delete($key) { } /** - * Delete all keys from the cache. This will clear every cache value stored - * in wincache. + * Delete all keys from the cache. This will clear every + * item in the cache matching the cache config prefix. * - * @return boolean True if the cache was successfully cleared, false otherwise + * + * @param boolean $check If true, nothing will be cleared, as entries will + * naturally expire in wincache.. + * @return boolean True Returns true. */ public function clear($check) { - return wincache_ucache_clear(); + if ($check) { + return true; + } + $info = wincache_ucache_info(); + $cacheKeys = $info['ucache_entries']; + unset($info); + foreach ($cacheKeys as $key) { + if (strpos($key['key_name'], $this->settings['prefix']) === 0) { + wincache_ucache_delete($key['key_name']); + } + } + return true; } } diff --git a/lib/Cake/Test/Case/Cache/Engine/WincacheEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/WincacheEngineTest.php index 4a86413ac47..c64782a2daa 100644 --- a/lib/Cake/Test/Case/Cache/Engine/WincacheEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/WincacheEngineTest.php @@ -188,10 +188,12 @@ public function testIncrement() { * @return void */ public function testClear() { + wincache_ucache_set('not_cake', 'safe'); Cache::write('some_value', 'value', 'wincache'); $result = Cache::clear(false, 'wincache'); $this->assertTrue($result); $this->assertFalse(Cache::read('some_value', 'wincache')); + $this->assertEquals('safe', wincache_ucache_get('not_cake')); } }