Esempio n. 1
0
 public function __construct($prefix = '')
 {
     parent::__construct($prefix);
     if (is_null(self::$cache)) {
         self::$cache = \OC::$server->getGetRedisFactory()->getInstance();
     }
 }
Esempio n. 2
0
 /**
  * Load the specified class
  *
  * @param string $class
  * @return bool
  */
 public function load($class)
 {
     $pathsToRequire = null;
     if ($this->memoryCache) {
         $pathsToRequire = $this->memoryCache->get($class);
     }
     if (!is_array($pathsToRequire)) {
         // No cache or cache miss
         $pathsToRequire = array();
         foreach ($this->findClass($class) as $path) {
             $fullPath = stream_resolve_include_path($path);
             if ($fullPath) {
                 $pathsToRequire[] = $fullPath;
             }
         }
         if ($this->memoryCache) {
             $this->memoryCache->set($class, $pathsToRequire, 60);
             // cache 60 sec
         }
     }
     foreach ($pathsToRequire as $fullPath) {
         require_once $fullPath;
     }
     return false;
 }
Esempio n. 3
0
 public function __construct($prefix = '')
 {
     parent::__construct($prefix);
     if (is_null(self::$cache)) {
         // TODO allow configuring a RedisArray, see https://github.com/nicolasff/phpredis/blob/master/arrays.markdown#redis-arrays
         self::$cache = new \Redis();
         $config = \OC::$server->getSystemConfig()->getValue('redis', array());
         if (isset($config['host'])) {
             $host = $config['host'];
         } else {
             $host = '127.0.0.1';
         }
         if (isset($config['port'])) {
             $port = $config['port'];
         } else {
             $port = 6379;
         }
         if (isset($config['timeout'])) {
             $timeout = $config['timeout'];
         } else {
             $timeout = 0.0;
             // unlimited
         }
         self::$cache->connect($host, $port, $timeout);
         if (isset($config['dbindex'])) {
             self::$cache->select($config['dbindex']);
         }
     }
 }
Esempio n. 4
0
 public function __construct($prefix = '')
 {
     parent::__construct($prefix);
     if (is_null(self::$cache)) {
         self::$cache = new \Memcached();
         $servers = \OC::$server->getSystemConfig()->getValue('memcached_servers');
         if (!$servers) {
             $server = \OC::$server->getSystemConfig()->getValue('memcached_server');
             if ($server) {
                 $servers = array($server);
             } else {
                 $servers = array(array('localhost', 11211));
             }
         }
         self::$cache->addServers($servers);
         $defaultOptions = [\Memcached::OPT_CONNECT_TIMEOUT => 50, \Memcached::OPT_RETRY_TIMEOUT => 50, \Memcached::OPT_SEND_TIMEOUT => 50, \Memcached::OPT_RECV_TIMEOUT => 50, \Memcached::OPT_POLL_TIMEOUT => 50, \Memcached::OPT_COMPRESSION => true, \Memcached::OPT_LIBKETAMA_COMPATIBLE => true, \Memcached::OPT_BINARY_PROTOCOL => true];
         // by default enable igbinary serializer if available
         if (\Memcached::HAVE_IGBINARY) {
             $defaultOptions[\Memcached::OPT_SERIALIZER] = \Memcached::SERIALIZER_IGBINARY;
         }
         $options = \OC::$server->getConfig()->getSystemValue('memcached_options', []);
         if (is_array($options)) {
             $options = $options + $defaultOptions;
             self::$cache->setOptions($options);
         } else {
             throw new HintException("Expected 'memcached_options' config to be an array, got {$options}");
         }
     }
 }
Esempio n. 5
0
 public function __construct($prefix = '')
 {
     parent::__construct($prefix);
     if (is_null(self::$cache)) {
         self::$cache = new \Memcached();
         $servers = \OC_Config::getValue('memcached_servers');
         if (!$servers) {
             $server = \OC_Config::getValue('memcached_server');
             if ($server) {
                 $servers = array($server);
             } else {
                 $servers = array(array('localhost', 11211));
             }
         }
         self::$cache->addServers($servers);
     }
 }