summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2015-05-08 13:27:27 +0200
committerArthur Schiwon <blizzz@owncloud.com>2015-05-08 13:27:27 +0200
commit90611e65943adc9d58ce04b5e08978c6dc122a68 (patch)
tree25389aaca266c9d76a97ef0a22cea6020d8e577d /apps
parentebf3953908a8dfdb754a5031d69326c6b83cf609 (diff)
downloadnextcloud-server-90611e65943adc9d58ce04b5e08978c6dc122a68.tar.gz
nextcloud-server-90611e65943adc9d58ce04b5e08978c6dc122a68.zip
only use memcache, if available
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/lib/proxy.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/apps/user_ldap/lib/proxy.php b/apps/user_ldap/lib/proxy.php
index 1cc81b8d1d5..347ea9ce6a9 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));
}
}