]> source.dussan.org Git - nextcloud-server.git/commitdiff
add debug log for memcache instantiation
authorJörn Friedrich Dreyer <jfd@butonic.de>
Wed, 4 Feb 2015 11:15:40 +0000 (12:15 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Mon, 16 Feb 2015 17:05:43 +0000 (18:05 +0100)
lib/base.php
lib/private/memcache/factory.php
lib/private/server.php

index 8a79d4624d85fb4fb48edba4e50986214a845f53..db758958577dfe48344c84235f3895b5590179c9 100644 (file)
@@ -708,7 +708,8 @@ class OC {
                $instanceId = \OC::$server->getSystemConfig()->getValue('instanceid', null);
                if ($instanceId) {
                        try {
-                               $memcacheFactory = new \OC\Memcache\Factory($instanceId);
+                               $memcacheFactory = new \OC\Memcache\Factory($instanceId,
+                                       \OC::$server->getLogger());
                                self::$loader->setMemoryCache($memcacheFactory->createLowLatency('Autoloader'));
                        } catch (\Exception $ex) {
                        }
index e8a91c522691a81df70e2d71167ff42b0b2fbdf3..537054a30f62817d25f1b5849d056f7a7b63db48 100644 (file)
@@ -11,16 +11,19 @@ namespace OC\Memcache;
 use \OCP\ICacheFactory;
 
 class Factory implements ICacheFactory {
-       /**
-        * @var string $globalPrefix
-        */
+       /** @var string $globalPrefix */
        private $globalPrefix;
 
+       /** @var \OCP\ILogger */
+       private $logger;
+
        /**
         * @param string $globalPrefix
+        * @param \OCP\ILogger $logger
         */
-       public function __construct($globalPrefix) {
+       public function __construct($globalPrefix, $logger) {
                $this->globalPrefix = $globalPrefix;
+               $this->logger = $logger;
        }
 
        /**
@@ -32,16 +35,22 @@ class Factory implements ICacheFactory {
        function create($prefix = '') {
                $prefix = $this->globalPrefix . '/' . $prefix;
                if (XCache::isAvailable()) {
+                       $this->logger->debug("creating XCache instance", array('app' => 'memcache'));
                        return new XCache($prefix);
                } elseif (APCu::isAvailable()) {
+                       $this->logger->debug('creating APCu instance', array('app'=>'memcache'));
                        return new APCu($prefix);
                } elseif (APC::isAvailable()) {
+                       $this->logger->debug('creating APC instance', array('app'=>'memcache'));
                        return new APC($prefix);
                } elseif (Redis::isAvailable()) {
+                       $this->logger->debug('creating redis instance', array('app'=>'memcache'));
                        return new Redis($prefix);
                } elseif (Memcached::isAvailable()) {
+                       $this->logger->debug('creating memcached instance', array('app'=>'memcache'));
                        return new Memcached($prefix);
                } else {
+                       $this->logger->debug('no cache available instance', array('app'=>'memcache'));
                        return new ArrayCache($prefix);
                }
        }
@@ -64,12 +73,16 @@ class Factory implements ICacheFactory {
        public function createLowLatency($prefix = '') {
                $prefix = $this->globalPrefix . '/' . $prefix;
                if (XCache::isAvailable()) {
+                       $this->logger->debug('creating xcache instance for low latency', array('app'=>'memcache'));
                        return new XCache($prefix);
                } elseif (APCu::isAvailable()) {
+                       $this->logger->debug('creating APCu instance for low latency', array('app'=>'memcache'));
                        return new APCu($prefix);
                } elseif (APC::isAvailable()) {
+                       $this->logger->debug('creating APC instance for low latency', array('app'=>'memcache'));
                        return new APC($prefix);
                } else {
+                       $this->logger->debug('no low latency cache available', array('app'=>'memcache'));
                        return null;
                }
        }
@@ -83,5 +96,4 @@ class Factory implements ICacheFactory {
                return XCache::isAvailable() || APCu::isAvailable() || APC::isAvailable();
        }
 
-
 }
index b023534ae2145f37a96d669244ffda11ddabf370..9660597b39dd3ad2967ad7533511d065b2cf0141 100644 (file)
@@ -193,7 +193,8 @@ class Server extends SimpleContainer implements IServerContainer {
                });
                $this->registerService('MemCacheFactory', function ($c) {
                        $instanceId = \OC_Util::getInstanceId();
-                       return new \OC\Memcache\Factory($instanceId);
+                       $logger = $c['Logger'];
+                       return new \OC\Memcache\Factory($instanceId, $logger);
                });
                $this->registerService('ActivityManager', function ($c) {
                        return new ActivityManager();