Skip to content

Commit

Permalink
Memcache\Factory: Remove static, use globalPrefix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Fischer committed Jul 29, 2014
1 parent da391b8 commit 9be8ac5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions lib/base.php
Expand Up @@ -477,9 +477,18 @@ public static function init() {
self::handleAuthHeaders();

self::initPaths();
if (OC_Config::getValue('instanceid', false)) {

// The class loader takes an optional low-latency cache, which MUST be
// namespaced. The instanceid is used for namespacing, but might be
// unavailable at this point. Futhermore, it might not be possible to
// generate an instanceid via \OC_Util::getInstanceId() because the
// config file may not be writable. As such, we only register a class
// loader cache if instanceid is available without trying to create one.
$instanceId = OC_Config::getValue('instanceid', null);
if ($instanceId) {
try {
self::$loader->setMemoryCache(\OC\Memcache\Factory::createLowLatency('Autoloader'));
$memcacheFactory = new \OC\Memcache\Factory($instanceId);
self::$loader->setMemoryCache($memcacheFactory->createLowLatency('Autoloader'));
} catch (\Exception $ex) {
}
}
Expand Down
5 changes: 3 additions & 2 deletions lib/private/memcache/factory.php
Expand Up @@ -59,7 +59,8 @@ public function isAvailable() {
* @param string $prefix
* @return null|Cache
*/
public static function createLowLatency($prefix = '') {
public function createLowLatency($prefix = '') {
$prefix = $this->globalPrefix . '/' . $prefix;
if (XCache::isAvailable()) {
return new XCache($prefix);
} elseif (APCu::isAvailable()) {
Expand All @@ -76,7 +77,7 @@ public static function createLowLatency($prefix = '') {
*
* @return bool
*/
public static function isAvailableLowLatency() {
public function isAvailableLowLatency() {
return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable();
}

Expand Down

0 comments on commit 9be8ac5

Please sign in to comment.