[Pkg-owncloud-commits] [owncloud] 05/457: only use memcache, if available
David Prévot
taffit at moszumanska.debian.org
Sun Jun 28 20:05:15 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit 90611e65943adc9d58ce04b5e08978c6dc122a68
Author: Arthur Schiwon <blizzz at owncloud.com>
Date: Fri May 8 13:27:27 2015 +0200
only use memcache, if available
---
apps/user_ldap/lib/proxy.php | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/apps/user_ldap/lib/proxy.php b/apps/user_ldap/lib/proxy.php
index 1cc81b8..347ea9c 100644
--- a/apps/user_ldap/lib/proxy.php
+++ b/apps/user_ldap/lib/proxy.php
@@ -37,12 +37,18 @@ abstract class Proxy {
static private $accesses = array();
private $ldap = null;
+ /** @var \OCP\ICache|null */
+ private $cache;
+
/**
* @param ILDAPWrapper $ldap
*/
public function __construct(ILDAPWrapper $ldap) {
$this->ldap = $ldap;
- $this->cache = \OC\Cache::getGlobalCache();
+ $memcache = \OC::$server->getMemCacheFactory();
+ if($memcache->isAvailable()) {
+ $this->cache = $memcache->create();
+ }
}
/**
@@ -151,7 +157,7 @@ abstract class Proxy {
* @return mixed|null
*/
public function getFromCache($key) {
- if(!$this->isCached($key)) {
+ if(is_null($this->cache) || !$this->isCached($key)) {
return null;
}
$key = $this->getCacheKey($key);
@@ -164,6 +170,9 @@ abstract class Proxy {
* @return bool
*/
public function isCached($key) {
+ if(is_null($this->cache)) {
+ return false;
+ }
$key = $this->getCacheKey($key);
return $this->cache->hasKey($key);
}
@@ -173,12 +182,18 @@ abstract class Proxy {
* @param mixed $value
*/
public function writeToCache($key, $value) {
+ if(is_null($this->cache)) {
+ return;
+ }
$key = $this->getCacheKey($key);
$value = base64_encode(serialize($value));
$this->cache->set($key, $value, '2592000');
}
public function clearCache() {
+ if(is_null($this->cache)) {
+ return;
+ }
$this->cache->clear($this->getCacheKey(null));
}
}
--
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