[Pkg-owncloud-commits] [owncloud] 03/16: Fallback to complete Memcached flush if getAllKeys fails
David Prévot
taffit at moszumanska.debian.org
Thu Oct 22 15:55:36 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 3bc4c92d7654b3f7a7e6fa7cdc9738a92c956d2d
Author: Robin McCorkell <rmccorkell at owncloud.com>
Date: Sat Sep 5 20:02:49 2015 +0100
Fallback to complete Memcached flush if getAllKeys fails
Newer Memcached's do not support the underlying protocol commands that
getAllKeys() is implemented with. We should fallback to clearing
everything in that case, as causing (temporary) performance problems for
other applications on the server is better than having stale cached data.
---
lib/private/memcache/memcached.php | 5 +++++
tests/lib/memcache/memcached.php | 23 +++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/lib/private/memcache/memcached.php b/lib/private/memcache/memcached.php
index cd8e2e8..aaa9f58 100644
--- a/lib/private/memcache/memcached.php
+++ b/lib/private/memcache/memcached.php
@@ -67,6 +67,11 @@ class Memcached extends Cache {
public function clear($prefix = '') {
$prefix = $this->getNamespace() . $prefix;
$allKeys = self::$cache->getAllKeys();
+ if ($allKeys === false) {
+ // newer Memcached doesn't like getAllKeys(), flush everything
+ self::$cache->flush();
+ return true;
+ }
$keys = array();
$prefixLength = strlen($prefix);
foreach ($allKeys as $key) {
diff --git a/tests/lib/memcache/memcached.php b/tests/lib/memcache/memcached.php
index fdab326..6f6acc4 100644
--- a/tests/lib/memcache/memcached.php
+++ b/tests/lib/memcache/memcached.php
@@ -23,4 +23,27 @@ class Memcached extends Cache {
public function setUp() {
$this->instance = new \OC\Memcache\Memcached(uniqid());
}
+
+ public function testClear() {
+ // Memcached is sometimes broken with clear(), so we don't test it thoroughly
+ $value='ipsum lorum';
+ $this->instance->set('1_value1', $value);
+ $this->instance->set('1_value2', $value);
+ $this->instance->set('2_value1', $value);
+ $this->instance->set('3_value1', $value);
+
+ $this->assertTrue($this->instance->clear('1_'));
+
+ $this->assertFalse($this->instance->hasKey('1_value1'));
+ $this->assertFalse($this->instance->hasKey('1_value2'));
+ //$this->assertTrue($this->instance->hasKey('2_value1'));
+ //$this->assertTrue($this->instance->hasKey('3_value1'));
+
+ $this->assertTrue($this->instance->clear());
+
+ $this->assertFalse($this->instance->hasKey('1_value1'));
+ $this->assertFalse($this->instance->hasKey('1_value2'));
+ $this->assertFalse($this->instance->hasKey('2_value1'));
+ $this->assertFalse($this->instance->hasKey('3_value1'));
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list