Exemplo n.º 1
0
 public function __construct($prefix = '')
 {
     parent::__construct($prefix);
     if (is_null(self::$cache)) {
         self::$cache = \OC::$server->getGetRedisFactory()->getInstance();
     }
 }
Exemplo n.º 2
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']);
         }
     }
 }
Exemplo n.º 3
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}");
         }
     }
 }
Exemplo n.º 4
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);
     }
 }