@@ -29,153 +29,153 @@ |
||
| 29 | 29 | use OCP\IMemcacheTTL; |
| 30 | 30 | |
| 31 | 31 | class Redis extends Cache implements IMemcacheTTL { |
| 32 | - /** |
|
| 33 | - * @var \Redis $cache |
|
| 34 | - */ |
|
| 35 | - private static $cache = null; |
|
| 36 | - |
|
| 37 | - public function __construct($prefix = '') { |
|
| 38 | - parent::__construct($prefix); |
|
| 39 | - if (is_null(self::$cache)) { |
|
| 40 | - self::$cache = \OC::$server->getGetRedisFactory()->getInstance(); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * entries in redis get namespaced to prevent collisions between ownCloud instances and users |
|
| 46 | - */ |
|
| 47 | - protected function getNameSpace() { |
|
| 48 | - return $this->prefix; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public function get($key) { |
|
| 52 | - $result = self::$cache->get($this->getNameSpace() . $key); |
|
| 53 | - if ($result === false && !self::$cache->exists($this->getNameSpace() . $key)) { |
|
| 54 | - return null; |
|
| 55 | - } else { |
|
| 56 | - return json_decode($result, true); |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - public function set($key, $value, $ttl = 0) { |
|
| 61 | - if ($ttl > 0) { |
|
| 62 | - return self::$cache->setex($this->getNameSpace() . $key, $ttl, json_encode($value)); |
|
| 63 | - } else { |
|
| 64 | - return self::$cache->set($this->getNameSpace() . $key, json_encode($value)); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - public function hasKey($key) { |
|
| 69 | - return self::$cache->exists($this->getNameSpace() . $key); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - public function remove($key) { |
|
| 73 | - if (self::$cache->delete($this->getNameSpace() . $key)) { |
|
| 74 | - return true; |
|
| 75 | - } else { |
|
| 76 | - return false; |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - public function clear($prefix = '') { |
|
| 81 | - $prefix = $this->getNameSpace() . $prefix . '*'; |
|
| 82 | - $it = null; |
|
| 83 | - self::$cache->setOption(\Redis::OPT_SCAN, \Redis::SCAN_RETRY); |
|
| 84 | - while ($keys = self::$cache->scan($it, $prefix)) { |
|
| 85 | - self::$cache->delete($keys); |
|
| 86 | - } |
|
| 87 | - return true; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Set a value in the cache if it's not already stored |
|
| 92 | - * |
|
| 93 | - * @param string $key |
|
| 94 | - * @param mixed $value |
|
| 95 | - * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 |
|
| 96 | - * @return bool |
|
| 97 | - */ |
|
| 98 | - public function add($key, $value, $ttl = 0) { |
|
| 99 | - // don't encode ints for inc/dec |
|
| 100 | - if (!is_int($value)) { |
|
| 101 | - $value = json_encode($value); |
|
| 102 | - } |
|
| 103 | - return self::$cache->setnx($this->getPrefix() . $key, $value); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Increase a stored number |
|
| 108 | - * |
|
| 109 | - * @param string $key |
|
| 110 | - * @param int $step |
|
| 111 | - * @return int | bool |
|
| 112 | - */ |
|
| 113 | - public function inc($key, $step = 1) { |
|
| 114 | - return self::$cache->incrBy($this->getNameSpace() . $key, $step); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Decrease a stored number |
|
| 119 | - * |
|
| 120 | - * @param string $key |
|
| 121 | - * @param int $step |
|
| 122 | - * @return int | bool |
|
| 123 | - */ |
|
| 124 | - public function dec($key, $step = 1) { |
|
| 125 | - if (!$this->hasKey($key)) { |
|
| 126 | - return false; |
|
| 127 | - } |
|
| 128 | - return self::$cache->decrBy($this->getNameSpace() . $key, $step); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Compare and set |
|
| 133 | - * |
|
| 134 | - * @param string $key |
|
| 135 | - * @param mixed $old |
|
| 136 | - * @param mixed $new |
|
| 137 | - * @return bool |
|
| 138 | - */ |
|
| 139 | - public function cas($key, $old, $new) { |
|
| 140 | - if (!is_int($new)) { |
|
| 141 | - $new = json_encode($new); |
|
| 142 | - } |
|
| 143 | - self::$cache->watch($this->getNameSpace() . $key); |
|
| 144 | - if ($this->get($key) === $old) { |
|
| 145 | - $result = self::$cache->multi() |
|
| 146 | - ->set($this->getNameSpace() . $key, $new) |
|
| 147 | - ->exec(); |
|
| 148 | - return ($result === false) ? false : true; |
|
| 149 | - } |
|
| 150 | - self::$cache->unwatch(); |
|
| 151 | - return false; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Compare and delete |
|
| 156 | - * |
|
| 157 | - * @param string $key |
|
| 158 | - * @param mixed $old |
|
| 159 | - * @return bool |
|
| 160 | - */ |
|
| 161 | - public function cad($key, $old) { |
|
| 162 | - self::$cache->watch($this->getNameSpace() . $key); |
|
| 163 | - if ($this->get($key) === $old) { |
|
| 164 | - $result = self::$cache->multi() |
|
| 165 | - ->del($this->getNameSpace() . $key) |
|
| 166 | - ->exec(); |
|
| 167 | - return ($result === false) ? false : true; |
|
| 168 | - } |
|
| 169 | - self::$cache->unwatch(); |
|
| 170 | - return false; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - public function setTTL($key, $ttl) { |
|
| 174 | - self::$cache->expire($this->getNameSpace() . $key, $ttl); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - static public function isAvailable() { |
|
| 178 | - return \OC::$server->getGetRedisFactory()->isAvailable(); |
|
| 179 | - } |
|
| 32 | + /** |
|
| 33 | + * @var \Redis $cache |
|
| 34 | + */ |
|
| 35 | + private static $cache = null; |
|
| 36 | + |
|
| 37 | + public function __construct($prefix = '') { |
|
| 38 | + parent::__construct($prefix); |
|
| 39 | + if (is_null(self::$cache)) { |
|
| 40 | + self::$cache = \OC::$server->getGetRedisFactory()->getInstance(); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * entries in redis get namespaced to prevent collisions between ownCloud instances and users |
|
| 46 | + */ |
|
| 47 | + protected function getNameSpace() { |
|
| 48 | + return $this->prefix; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public function get($key) { |
|
| 52 | + $result = self::$cache->get($this->getNameSpace() . $key); |
|
| 53 | + if ($result === false && !self::$cache->exists($this->getNameSpace() . $key)) { |
|
| 54 | + return null; |
|
| 55 | + } else { |
|
| 56 | + return json_decode($result, true); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + public function set($key, $value, $ttl = 0) { |
|
| 61 | + if ($ttl > 0) { |
|
| 62 | + return self::$cache->setex($this->getNameSpace() . $key, $ttl, json_encode($value)); |
|
| 63 | + } else { |
|
| 64 | + return self::$cache->set($this->getNameSpace() . $key, json_encode($value)); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + public function hasKey($key) { |
|
| 69 | + return self::$cache->exists($this->getNameSpace() . $key); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + public function remove($key) { |
|
| 73 | + if (self::$cache->delete($this->getNameSpace() . $key)) { |
|
| 74 | + return true; |
|
| 75 | + } else { |
|
| 76 | + return false; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + public function clear($prefix = '') { |
|
| 81 | + $prefix = $this->getNameSpace() . $prefix . '*'; |
|
| 82 | + $it = null; |
|
| 83 | + self::$cache->setOption(\Redis::OPT_SCAN, \Redis::SCAN_RETRY); |
|
| 84 | + while ($keys = self::$cache->scan($it, $prefix)) { |
|
| 85 | + self::$cache->delete($keys); |
|
| 86 | + } |
|
| 87 | + return true; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Set a value in the cache if it's not already stored |
|
| 92 | + * |
|
| 93 | + * @param string $key |
|
| 94 | + * @param mixed $value |
|
| 95 | + * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 |
|
| 96 | + * @return bool |
|
| 97 | + */ |
|
| 98 | + public function add($key, $value, $ttl = 0) { |
|
| 99 | + // don't encode ints for inc/dec |
|
| 100 | + if (!is_int($value)) { |
|
| 101 | + $value = json_encode($value); |
|
| 102 | + } |
|
| 103 | + return self::$cache->setnx($this->getPrefix() . $key, $value); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Increase a stored number |
|
| 108 | + * |
|
| 109 | + * @param string $key |
|
| 110 | + * @param int $step |
|
| 111 | + * @return int | bool |
|
| 112 | + */ |
|
| 113 | + public function inc($key, $step = 1) { |
|
| 114 | + return self::$cache->incrBy($this->getNameSpace() . $key, $step); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Decrease a stored number |
|
| 119 | + * |
|
| 120 | + * @param string $key |
|
| 121 | + * @param int $step |
|
| 122 | + * @return int | bool |
|
| 123 | + */ |
|
| 124 | + public function dec($key, $step = 1) { |
|
| 125 | + if (!$this->hasKey($key)) { |
|
| 126 | + return false; |
|
| 127 | + } |
|
| 128 | + return self::$cache->decrBy($this->getNameSpace() . $key, $step); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Compare and set |
|
| 133 | + * |
|
| 134 | + * @param string $key |
|
| 135 | + * @param mixed $old |
|
| 136 | + * @param mixed $new |
|
| 137 | + * @return bool |
|
| 138 | + */ |
|
| 139 | + public function cas($key, $old, $new) { |
|
| 140 | + if (!is_int($new)) { |
|
| 141 | + $new = json_encode($new); |
|
| 142 | + } |
|
| 143 | + self::$cache->watch($this->getNameSpace() . $key); |
|
| 144 | + if ($this->get($key) === $old) { |
|
| 145 | + $result = self::$cache->multi() |
|
| 146 | + ->set($this->getNameSpace() . $key, $new) |
|
| 147 | + ->exec(); |
|
| 148 | + return ($result === false) ? false : true; |
|
| 149 | + } |
|
| 150 | + self::$cache->unwatch(); |
|
| 151 | + return false; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Compare and delete |
|
| 156 | + * |
|
| 157 | + * @param string $key |
|
| 158 | + * @param mixed $old |
|
| 159 | + * @return bool |
|
| 160 | + */ |
|
| 161 | + public function cad($key, $old) { |
|
| 162 | + self::$cache->watch($this->getNameSpace() . $key); |
|
| 163 | + if ($this->get($key) === $old) { |
|
| 164 | + $result = self::$cache->multi() |
|
| 165 | + ->del($this->getNameSpace() . $key) |
|
| 166 | + ->exec(); |
|
| 167 | + return ($result === false) ? false : true; |
|
| 168 | + } |
|
| 169 | + self::$cache->unwatch(); |
|
| 170 | + return false; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + public function setTTL($key, $ttl) { |
|
| 174 | + self::$cache->expire($this->getNameSpace() . $key, $ttl); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + static public function isAvailable() { |
|
| 178 | + return \OC::$server->getGetRedisFactory()->isAvailable(); |
|
| 179 | + } |
|
| 180 | 180 | } |
| 181 | 181 | |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | public function get($key) { |
| 52 | - $result = self::$cache->get($this->getNameSpace() . $key); |
|
| 53 | - if ($result === false && !self::$cache->exists($this->getNameSpace() . $key)) { |
|
| 52 | + $result = self::$cache->get($this->getNameSpace().$key); |
|
| 53 | + if ($result === false && !self::$cache->exists($this->getNameSpace().$key)) { |
|
| 54 | 54 | return null; |
| 55 | 55 | } else { |
| 56 | 56 | return json_decode($result, true); |
@@ -59,18 +59,18 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | public function set($key, $value, $ttl = 0) { |
| 61 | 61 | if ($ttl > 0) { |
| 62 | - return self::$cache->setex($this->getNameSpace() . $key, $ttl, json_encode($value)); |
|
| 62 | + return self::$cache->setex($this->getNameSpace().$key, $ttl, json_encode($value)); |
|
| 63 | 63 | } else { |
| 64 | - return self::$cache->set($this->getNameSpace() . $key, json_encode($value)); |
|
| 64 | + return self::$cache->set($this->getNameSpace().$key, json_encode($value)); |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | public function hasKey($key) { |
| 69 | - return self::$cache->exists($this->getNameSpace() . $key); |
|
| 69 | + return self::$cache->exists($this->getNameSpace().$key); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public function remove($key) { |
| 73 | - if (self::$cache->delete($this->getNameSpace() . $key)) { |
|
| 73 | + if (self::$cache->delete($this->getNameSpace().$key)) { |
|
| 74 | 74 | return true; |
| 75 | 75 | } else { |
| 76 | 76 | return false; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public function clear($prefix = '') { |
| 81 | - $prefix = $this->getNameSpace() . $prefix . '*'; |
|
| 81 | + $prefix = $this->getNameSpace().$prefix.'*'; |
|
| 82 | 82 | $it = null; |
| 83 | 83 | self::$cache->setOption(\Redis::OPT_SCAN, \Redis::SCAN_RETRY); |
| 84 | 84 | while ($keys = self::$cache->scan($it, $prefix)) { |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | if (!is_int($value)) { |
| 101 | 101 | $value = json_encode($value); |
| 102 | 102 | } |
| 103 | - return self::$cache->setnx($this->getPrefix() . $key, $value); |
|
| 103 | + return self::$cache->setnx($this->getPrefix().$key, $value); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @return int | bool |
| 112 | 112 | */ |
| 113 | 113 | public function inc($key, $step = 1) { |
| 114 | - return self::$cache->incrBy($this->getNameSpace() . $key, $step); |
|
| 114 | + return self::$cache->incrBy($this->getNameSpace().$key, $step); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | if (!$this->hasKey($key)) { |
| 126 | 126 | return false; |
| 127 | 127 | } |
| 128 | - return self::$cache->decrBy($this->getNameSpace() . $key, $step); |
|
| 128 | + return self::$cache->decrBy($this->getNameSpace().$key, $step); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | if (!is_int($new)) { |
| 141 | 141 | $new = json_encode($new); |
| 142 | 142 | } |
| 143 | - self::$cache->watch($this->getNameSpace() . $key); |
|
| 143 | + self::$cache->watch($this->getNameSpace().$key); |
|
| 144 | 144 | if ($this->get($key) === $old) { |
| 145 | 145 | $result = self::$cache->multi() |
| 146 | - ->set($this->getNameSpace() . $key, $new) |
|
| 146 | + ->set($this->getNameSpace().$key, $new) |
|
| 147 | 147 | ->exec(); |
| 148 | 148 | return ($result === false) ? false : true; |
| 149 | 149 | } |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | * @return bool |
| 160 | 160 | */ |
| 161 | 161 | public function cad($key, $old) { |
| 162 | - self::$cache->watch($this->getNameSpace() . $key); |
|
| 162 | + self::$cache->watch($this->getNameSpace().$key); |
|
| 163 | 163 | if ($this->get($key) === $old) { |
| 164 | 164 | $result = self::$cache->multi() |
| 165 | - ->del($this->getNameSpace() . $key) |
|
| 165 | + ->del($this->getNameSpace().$key) |
|
| 166 | 166 | ->exec(); |
| 167 | 167 | return ($result === false) ? false : true; |
| 168 | 168 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | public function setTTL($key, $ttl) { |
| 174 | - self::$cache->expire($this->getNameSpace() . $key, $ttl); |
|
| 174 | + self::$cache->expire($this->getNameSpace().$key, $ttl); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | static public function isAvailable() { |
@@ -23,86 +23,86 @@ |
||
| 23 | 23 | namespace OC; |
| 24 | 24 | |
| 25 | 25 | class RedisFactory { |
| 26 | - /** @var \Redis */ |
|
| 27 | - private $instance; |
|
| 26 | + /** @var \Redis */ |
|
| 27 | + private $instance; |
|
| 28 | 28 | |
| 29 | - /** @var SystemConfig */ |
|
| 30 | - private $config; |
|
| 29 | + /** @var SystemConfig */ |
|
| 30 | + private $config; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * RedisFactory constructor. |
|
| 34 | - * |
|
| 35 | - * @param SystemConfig $config |
|
| 36 | - */ |
|
| 37 | - public function __construct(SystemConfig $config) { |
|
| 38 | - $this->config = $config; |
|
| 39 | - } |
|
| 32 | + /** |
|
| 33 | + * RedisFactory constructor. |
|
| 34 | + * |
|
| 35 | + * @param SystemConfig $config |
|
| 36 | + */ |
|
| 37 | + public function __construct(SystemConfig $config) { |
|
| 38 | + $this->config = $config; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - private function create() { |
|
| 42 | - if ($config = $this->config->getValue('redis.cluster', [])) { |
|
| 43 | - if (!class_exists('RedisCluster')) { |
|
| 44 | - throw new \Exception('Redis Cluster support is not available'); |
|
| 45 | - } |
|
| 46 | - // cluster config |
|
| 47 | - if (isset($config['timeout'])) { |
|
| 48 | - $timeout = $config['timeout']; |
|
| 49 | - } else { |
|
| 50 | - $timeout = null; |
|
| 51 | - } |
|
| 52 | - if (isset($config['read_timeout'])) { |
|
| 53 | - $readTimeout = $config['read_timeout']; |
|
| 54 | - } else { |
|
| 55 | - $readTimeout = null; |
|
| 56 | - } |
|
| 57 | - $this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout); |
|
| 41 | + private function create() { |
|
| 42 | + if ($config = $this->config->getValue('redis.cluster', [])) { |
|
| 43 | + if (!class_exists('RedisCluster')) { |
|
| 44 | + throw new \Exception('Redis Cluster support is not available'); |
|
| 45 | + } |
|
| 46 | + // cluster config |
|
| 47 | + if (isset($config['timeout'])) { |
|
| 48 | + $timeout = $config['timeout']; |
|
| 49 | + } else { |
|
| 50 | + $timeout = null; |
|
| 51 | + } |
|
| 52 | + if (isset($config['read_timeout'])) { |
|
| 53 | + $readTimeout = $config['read_timeout']; |
|
| 54 | + } else { |
|
| 55 | + $readTimeout = null; |
|
| 56 | + } |
|
| 57 | + $this->instance = new \RedisCluster(null, $config['seeds'], $timeout, $readTimeout); |
|
| 58 | 58 | |
| 59 | - if (isset($config['failover_mode'])) { |
|
| 60 | - $this->instance->setOption(\RedisCluster::OPT_SLAVE_FAILOVER, $config['failover_mode']); |
|
| 61 | - } |
|
| 62 | - } else { |
|
| 59 | + if (isset($config['failover_mode'])) { |
|
| 60 | + $this->instance->setOption(\RedisCluster::OPT_SLAVE_FAILOVER, $config['failover_mode']); |
|
| 61 | + } |
|
| 62 | + } else { |
|
| 63 | 63 | |
| 64 | - $this->instance = new \Redis(); |
|
| 65 | - $config = $this->config->getValue('redis', []); |
|
| 66 | - if (isset($config['host'])) { |
|
| 67 | - $host = $config['host']; |
|
| 68 | - } else { |
|
| 69 | - $host = '127.0.0.1'; |
|
| 70 | - } |
|
| 71 | - if (isset($config['port'])) { |
|
| 72 | - $port = $config['port']; |
|
| 73 | - } else { |
|
| 74 | - $port = 6379; |
|
| 75 | - } |
|
| 76 | - if (isset($config['timeout'])) { |
|
| 77 | - $timeout = $config['timeout']; |
|
| 78 | - } else { |
|
| 79 | - $timeout = 0.0; // unlimited |
|
| 80 | - } |
|
| 64 | + $this->instance = new \Redis(); |
|
| 65 | + $config = $this->config->getValue('redis', []); |
|
| 66 | + if (isset($config['host'])) { |
|
| 67 | + $host = $config['host']; |
|
| 68 | + } else { |
|
| 69 | + $host = '127.0.0.1'; |
|
| 70 | + } |
|
| 71 | + if (isset($config['port'])) { |
|
| 72 | + $port = $config['port']; |
|
| 73 | + } else { |
|
| 74 | + $port = 6379; |
|
| 75 | + } |
|
| 76 | + if (isset($config['timeout'])) { |
|
| 77 | + $timeout = $config['timeout']; |
|
| 78 | + } else { |
|
| 79 | + $timeout = 0.0; // unlimited |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - $this->instance->connect($host, $port, $timeout); |
|
| 83 | - if (isset($config['password']) && $config['password'] !== '') { |
|
| 84 | - $this->instance->auth($config['password']); |
|
| 85 | - } |
|
| 82 | + $this->instance->connect($host, $port, $timeout); |
|
| 83 | + if (isset($config['password']) && $config['password'] !== '') { |
|
| 84 | + $this->instance->auth($config['password']); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - if (isset($config['dbindex'])) { |
|
| 88 | - $this->instance->select($config['dbindex']); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } |
|
| 87 | + if (isset($config['dbindex'])) { |
|
| 88 | + $this->instance->select($config['dbindex']); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - public function getInstance() { |
|
| 94 | - if (!$this->isAvailable()) { |
|
| 95 | - throw new \Exception('Redis support is not available'); |
|
| 96 | - } |
|
| 97 | - if (!$this->instance instanceof \Redis) { |
|
| 98 | - $this->create(); |
|
| 99 | - } |
|
| 93 | + public function getInstance() { |
|
| 94 | + if (!$this->isAvailable()) { |
|
| 95 | + throw new \Exception('Redis support is not available'); |
|
| 96 | + } |
|
| 97 | + if (!$this->instance instanceof \Redis) { |
|
| 98 | + $this->create(); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - return $this->instance; |
|
| 102 | - } |
|
| 101 | + return $this->instance; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - public function isAvailable() { |
|
| 105 | - return extension_loaded('redis') |
|
| 106 | - && version_compare(phpversion('redis'), '2.2.5', '>='); |
|
| 107 | - } |
|
| 104 | + public function isAvailable() { |
|
| 105 | + return extension_loaded('redis') |
|
| 106 | + && version_compare(phpversion('redis'), '2.2.5', '>='); |
|
| 107 | + } |
|
| 108 | 108 | } |
@@ -41,17 +41,17 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | 'instanceid' => '', |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * The salt used to hash all passwords, auto-generated by the Nextcloud |
|
| 46 | - * installer. (There are also per-user salts.) If you lose this salt you lose |
|
| 47 | - * all your passwords. This example is for documentation only, and you should |
|
| 48 | - * never use it. |
|
| 49 | - * |
|
| 50 | - * @deprecated This salt is deprecated and only used for legacy-compatibility, |
|
| 51 | - * developers should *NOT* use this value for anything nowadays. |
|
| 52 | - * |
|
| 53 | - * 'passwordsalt' => 'd3c944a9af095aa08f', |
|
| 54 | - */ |
|
| 44 | + /** |
|
| 45 | + * The salt used to hash all passwords, auto-generated by the Nextcloud |
|
| 46 | + * installer. (There are also per-user salts.) If you lose this salt you lose |
|
| 47 | + * all your passwords. This example is for documentation only, and you should |
|
| 48 | + * never use it. |
|
| 49 | + * |
|
| 50 | + * @deprecated This salt is deprecated and only used for legacy-compatibility, |
|
| 51 | + * developers should *NOT* use this value for anything nowadays. |
|
| 52 | + * |
|
| 53 | + * 'passwordsalt' => 'd3c944a9af095aa08f', |
|
| 54 | + */ |
|
| 55 | 55 | 'passwordsalt' => '', |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | * ubos-raspberry-pi.local and ubos-raspberry-pi-2.local |
| 68 | 68 | */ |
| 69 | 69 | 'trusted_domains' => |
| 70 | - array ( |
|
| 70 | + array ( |
|
| 71 | 71 | 'demo.example.org', |
| 72 | 72 | 'otherdomain.example.org', |
| 73 | - ), |
|
| 73 | + ), |
|
| 74 | 74 | |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -242,10 +242,10 @@ discard block |
||
| 242 | 242 | * IMAP (OC_User_IMAP), SMB (OC_User_SMB), and FTP (OC_User_FTP). |
| 243 | 243 | */ |
| 244 | 244 | 'user_backends' => array( |
| 245 | - array( |
|
| 246 | - 'class' => 'OC_User_IMAP', |
|
| 247 | - 'arguments' => array('{imap.gmail.com:993/imap/ssl}INBOX') |
|
| 248 | - ) |
|
| 245 | + array( |
|
| 246 | + 'class' => 'OC_User_IMAP', |
|
| 247 | + 'arguments' => array('{imap.gmail.com:993/imap/ssl}INBOX') |
|
| 248 | + ) |
|
| 249 | 249 | ), |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -699,9 +699,9 @@ discard block |
||
| 699 | 699 | * Defaults to an empty array. |
| 700 | 700 | */ |
| 701 | 701 | 'log.condition' => [ |
| 702 | - 'shared_secret' => '57b58edb6637fe3059b3595cf9c41b9', |
|
| 703 | - 'users' => ['sample-user'], |
|
| 704 | - 'apps' => ['files'], |
|
| 702 | + 'shared_secret' => '57b58edb6637fe3059b3595cf9c41b9', |
|
| 703 | + 'users' => ['sample-user'], |
|
| 704 | + 'apps' => ['files'], |
|
| 705 | 705 | ], |
| 706 | 706 | |
| 707 | 707 | /** |
@@ -761,11 +761,11 @@ discard block |
||
| 761 | 761 | * * iOS client : ``https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8`` |
| 762 | 762 | */ |
| 763 | 763 | 'customclient_desktop' => |
| 764 | - 'https://nextcloud.com/install/#install-clients', |
|
| 764 | + 'https://nextcloud.com/install/#install-clients', |
|
| 765 | 765 | 'customclient_android' => |
| 766 | - 'https://play.google.com/store/apps/details?id=com.nextcloud.client', |
|
| 766 | + 'https://play.google.com/store/apps/details?id=com.nextcloud.client', |
|
| 767 | 767 | 'customclient_ios' => |
| 768 | - 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8', |
|
| 768 | + 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8', |
|
| 769 | 769 | |
| 770 | 770 | /** |
| 771 | 771 | * Apps |
@@ -789,11 +789,11 @@ discard block |
||
| 789 | 789 | * indicates if a Web server can write files to that folder. |
| 790 | 790 | */ |
| 791 | 791 | 'apps_paths' => array( |
| 792 | - array( |
|
| 793 | - 'path'=> '/var/www/nextcloud/apps', |
|
| 794 | - 'url' => '/apps', |
|
| 795 | - 'writable' => true, |
|
| 796 | - ), |
|
| 792 | + array( |
|
| 793 | + 'path'=> '/var/www/nextcloud/apps', |
|
| 794 | + 'url' => '/apps', |
|
| 795 | + 'writable' => true, |
|
| 796 | + ), |
|
| 797 | 797 | ), |
| 798 | 798 | |
| 799 | 799 | /** |
@@ -867,8 +867,8 @@ discard block |
||
| 867 | 867 | * Defaults to ``''`` (empty string) |
| 868 | 868 | */ |
| 869 | 869 | 'preview_office_cl_parameters' => |
| 870 | - ' --headless --nologo --nofirststartwizard --invisible --norestore '. |
|
| 871 | - '--convert-to pdf --outdir ', |
|
| 870 | + ' --headless --nologo --nofirststartwizard --invisible --norestore '. |
|
| 871 | + '--convert-to pdf --outdir ', |
|
| 872 | 872 | |
| 873 | 873 | /** |
| 874 | 874 | * Only register providers that have been explicitly enabled |
@@ -915,14 +915,14 @@ discard block |
||
| 915 | 915 | * - OC\Preview\XBitmap |
| 916 | 916 | */ |
| 917 | 917 | 'enabledPreviewProviders' => array( |
| 918 | - 'OC\Preview\PNG', |
|
| 919 | - 'OC\Preview\JPEG', |
|
| 920 | - 'OC\Preview\GIF', |
|
| 921 | - 'OC\Preview\BMP', |
|
| 922 | - 'OC\Preview\XBitmap', |
|
| 923 | - 'OC\Preview\MP3', |
|
| 924 | - 'OC\Preview\TXT', |
|
| 925 | - 'OC\Preview\MarkDown' |
|
| 918 | + 'OC\Preview\PNG', |
|
| 919 | + 'OC\Preview\JPEG', |
|
| 920 | + 'OC\Preview\GIF', |
|
| 921 | + 'OC\Preview\BMP', |
|
| 922 | + 'OC\Preview\XBitmap', |
|
| 923 | + 'OC\Preview\MP3', |
|
| 924 | + 'OC\Preview\TXT', |
|
| 925 | + 'OC\Preview\MarkDown' |
|
| 926 | 926 | ), |
| 927 | 927 | |
| 928 | 928 | /** |
@@ -991,11 +991,11 @@ discard block |
||
| 991 | 991 | |
| 992 | 992 | /** |
| 993 | 993 | * Extra SSL options to be used for configuration. |
| 994 | - * |
|
| 994 | + * |
|
| 995 | 995 | * Defaults to an empty array. |
| 996 | 996 | */ |
| 997 | 997 | 'openssl' => array( |
| 998 | - 'config' => '/absolute/location/of/openssl.cnf', |
|
| 998 | + 'config' => '/absolute/location/of/openssl.cnf', |
|
| 999 | 999 | ), |
| 1000 | 1000 | |
| 1001 | 1001 | /** |
@@ -1049,11 +1049,11 @@ discard block |
||
| 1049 | 1049 | * for more information. |
| 1050 | 1050 | */ |
| 1051 | 1051 | 'redis' => [ |
| 1052 | - 'host' => 'localhost', // can also be a unix domain socket: '/tmp/redis.sock' |
|
| 1053 | - 'port' => 6379, |
|
| 1054 | - 'timeout' => 0.0, |
|
| 1055 | - 'password' => '', // Optional, if not defined no password will be used. |
|
| 1056 | - 'dbindex' => 0, // Optional, if undefined SELECT will not run and will use Redis Server's default DB Index. |
|
| 1052 | + 'host' => 'localhost', // can also be a unix domain socket: '/tmp/redis.sock' |
|
| 1053 | + 'port' => 6379, |
|
| 1054 | + 'timeout' => 0.0, |
|
| 1055 | + 'password' => '', // Optional, if not defined no password will be used. |
|
| 1056 | + 'dbindex' => 0, // Optional, if undefined SELECT will not run and will use Redis Server's default DB Index. |
|
| 1057 | 1057 | ], |
| 1058 | 1058 | |
| 1059 | 1059 | /** |
@@ -1070,13 +1070,13 @@ discard block |
||
| 1070 | 1070 | * - \RedisCluster::FAILOVER_DISTRIBUTE - randomly distribute read commands across master and slaves |
| 1071 | 1071 | */ |
| 1072 | 1072 | 'redis.cluster' => [ |
| 1073 | - 'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required |
|
| 1074 | - 'localhost:7000', |
|
| 1075 | - 'localhost:7001' |
|
| 1076 | - ], |
|
| 1077 | - 'timeout' => 0.0, |
|
| 1078 | - 'read_timeout' => 0.0, |
|
| 1079 | - 'failover_mode' => \RedisCluster::FAILOVER_DISTRIBUTE |
|
| 1073 | + 'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required |
|
| 1074 | + 'localhost:7000', |
|
| 1075 | + 'localhost:7001' |
|
| 1076 | + ], |
|
| 1077 | + 'timeout' => 0.0, |
|
| 1078 | + 'read_timeout' => 0.0, |
|
| 1079 | + 'failover_mode' => \RedisCluster::FAILOVER_DISTRIBUTE |
|
| 1080 | 1080 | ], |
| 1081 | 1081 | |
| 1082 | 1082 | |
@@ -1084,35 +1084,35 @@ discard block |
||
| 1084 | 1084 | * Server details for one or more memcached servers to use for memory caching. |
| 1085 | 1085 | */ |
| 1086 | 1086 | 'memcached_servers' => array( |
| 1087 | - // hostname, port and optional weight. Also see: |
|
| 1088 | - // http://www.php.net/manual/en/memcached.addservers.php |
|
| 1089 | - // http://www.php.net/manual/en/memcached.addserver.php |
|
| 1090 | - array('localhost', 11211), |
|
| 1091 | - //array('other.host.local', 11211), |
|
| 1087 | + // hostname, port and optional weight. Also see: |
|
| 1088 | + // http://www.php.net/manual/en/memcached.addservers.php |
|
| 1089 | + // http://www.php.net/manual/en/memcached.addserver.php |
|
| 1090 | + array('localhost', 11211), |
|
| 1091 | + //array('other.host.local', 11211), |
|
| 1092 | 1092 | ), |
| 1093 | 1093 | |
| 1094 | 1094 | /** |
| 1095 | 1095 | * Connection options for memcached, see http://apprize.info/php/scaling/15.html |
| 1096 | 1096 | */ |
| 1097 | 1097 | 'memcached_options' => array( |
| 1098 | - // Set timeouts to 50ms |
|
| 1099 | - \Memcached::OPT_CONNECT_TIMEOUT => 50, |
|
| 1100 | - \Memcached::OPT_RETRY_TIMEOUT => 50, |
|
| 1101 | - \Memcached::OPT_SEND_TIMEOUT => 50, |
|
| 1102 | - \Memcached::OPT_RECV_TIMEOUT => 50, |
|
| 1103 | - \Memcached::OPT_POLL_TIMEOUT => 50, |
|
| 1098 | + // Set timeouts to 50ms |
|
| 1099 | + \Memcached::OPT_CONNECT_TIMEOUT => 50, |
|
| 1100 | + \Memcached::OPT_RETRY_TIMEOUT => 50, |
|
| 1101 | + \Memcached::OPT_SEND_TIMEOUT => 50, |
|
| 1102 | + \Memcached::OPT_RECV_TIMEOUT => 50, |
|
| 1103 | + \Memcached::OPT_POLL_TIMEOUT => 50, |
|
| 1104 | 1104 | |
| 1105 | - // Enable compression |
|
| 1106 | - \Memcached::OPT_COMPRESSION => true, |
|
| 1105 | + // Enable compression |
|
| 1106 | + \Memcached::OPT_COMPRESSION => true, |
|
| 1107 | 1107 | |
| 1108 | - // Turn on consistent hashing |
|
| 1109 | - \Memcached::OPT_LIBKETAMA_COMPATIBLE => true, |
|
| 1108 | + // Turn on consistent hashing |
|
| 1109 | + \Memcached::OPT_LIBKETAMA_COMPATIBLE => true, |
|
| 1110 | 1110 | |
| 1111 | - // Enable Binary Protocol |
|
| 1112 | - \Memcached::OPT_BINARY_PROTOCOL => true, |
|
| 1111 | + // Enable Binary Protocol |
|
| 1112 | + \Memcached::OPT_BINARY_PROTOCOL => true, |
|
| 1113 | 1113 | |
| 1114 | - // Binary serializer vill be enabled if the igbinary PECL module is available |
|
| 1115 | - //\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_IGBINARY, |
|
| 1114 | + // Binary serializer vill be enabled if the igbinary PECL module is available |
|
| 1115 | + //\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_IGBINARY, |
|
| 1116 | 1116 | ), |
| 1117 | 1117 | |
| 1118 | 1118 | |
@@ -1158,31 +1158,31 @@ discard block |
||
| 1158 | 1158 | * One way to test is applying for a trystack account at http://trystack.org/ |
| 1159 | 1159 | */ |
| 1160 | 1160 | 'objectstore' => [ |
| 1161 | - 'class' => 'OC\\Files\\ObjectStore\\Swift', |
|
| 1162 | - 'arguments' => [ |
|
| 1163 | - // trystack will user your facebook id as the user name |
|
| 1164 | - 'username' => 'facebook100000123456789', |
|
| 1165 | - // in the trystack dashboard go to user -> settings -> API Password to |
|
| 1166 | - // generate a password |
|
| 1167 | - 'password' => 'Secr3tPaSSWoRdt7', |
|
| 1168 | - // must already exist in the objectstore, name can be different |
|
| 1169 | - 'container' => 'nextcloud', |
|
| 1170 | - // prefix to prepend to the fileid, default is 'oid:urn:' |
|
| 1171 | - 'objectPrefix' => 'oid:urn:', |
|
| 1172 | - // create the container if it does not exist. default is false |
|
| 1173 | - 'autocreate' => true, |
|
| 1174 | - // required, dev-/trystack defaults to 'RegionOne' |
|
| 1175 | - 'region' => 'RegionOne', |
|
| 1176 | - // The Identity / Keystone endpoint |
|
| 1177 | - 'url' => 'http://8.21.28.222:5000/v2.0', |
|
| 1178 | - // required on dev-/trystack |
|
| 1179 | - 'tenantName' => 'facebook100000123456789', |
|
| 1180 | - // dev-/trystack uses swift by default, the lib defaults to 'cloudFiles' |
|
| 1181 | - // if omitted |
|
| 1182 | - 'serviceName' => 'swift', |
|
| 1183 | - // The Interface / url Type, optional |
|
| 1184 | - 'urlType' => 'internal' |
|
| 1185 | - ], |
|
| 1161 | + 'class' => 'OC\\Files\\ObjectStore\\Swift', |
|
| 1162 | + 'arguments' => [ |
|
| 1163 | + // trystack will user your facebook id as the user name |
|
| 1164 | + 'username' => 'facebook100000123456789', |
|
| 1165 | + // in the trystack dashboard go to user -> settings -> API Password to |
|
| 1166 | + // generate a password |
|
| 1167 | + 'password' => 'Secr3tPaSSWoRdt7', |
|
| 1168 | + // must already exist in the objectstore, name can be different |
|
| 1169 | + 'container' => 'nextcloud', |
|
| 1170 | + // prefix to prepend to the fileid, default is 'oid:urn:' |
|
| 1171 | + 'objectPrefix' => 'oid:urn:', |
|
| 1172 | + // create the container if it does not exist. default is false |
|
| 1173 | + 'autocreate' => true, |
|
| 1174 | + // required, dev-/trystack defaults to 'RegionOne' |
|
| 1175 | + 'region' => 'RegionOne', |
|
| 1176 | + // The Identity / Keystone endpoint |
|
| 1177 | + 'url' => 'http://8.21.28.222:5000/v2.0', |
|
| 1178 | + // required on dev-/trystack |
|
| 1179 | + 'tenantName' => 'facebook100000123456789', |
|
| 1180 | + // dev-/trystack uses swift by default, the lib defaults to 'cloudFiles' |
|
| 1181 | + // if omitted |
|
| 1182 | + 'serviceName' => 'swift', |
|
| 1183 | + // The Interface / url Type, optional |
|
| 1184 | + 'urlType' => 'internal' |
|
| 1185 | + ], |
|
| 1186 | 1186 | ], |
| 1187 | 1187 | |
| 1188 | 1188 | |
@@ -1223,8 +1223,8 @@ discard block |
||
| 1223 | 1223 | * encryption in MySQL or specify a custom wait timeout on a cheap hoster. |
| 1224 | 1224 | */ |
| 1225 | 1225 | 'dbdriveroptions' => array( |
| 1226 | - PDO::MYSQL_ATTR_SSL_CA => '/file/path/to/ca_cert.pem', |
|
| 1227 | - PDO::MYSQL_ATTR_INIT_COMMAND => 'SET wait_timeout = 28800' |
|
| 1226 | + PDO::MYSQL_ATTR_SSL_CA => '/file/path/to/ca_cert.pem', |
|
| 1227 | + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET wait_timeout = 28800' |
|
| 1228 | 1228 | ), |
| 1229 | 1229 | |
| 1230 | 1230 | /** |
@@ -1276,10 +1276,10 @@ discard block |
||
| 1276 | 1276 | * - pgsql (PostgreSQL) |
| 1277 | 1277 | */ |
| 1278 | 1278 | 'supportedDatabases' => array( |
| 1279 | - 'sqlite', |
|
| 1280 | - 'mysql', |
|
| 1281 | - 'pgsql', |
|
| 1282 | - 'oci', |
|
| 1279 | + 'sqlite', |
|
| 1280 | + 'mysql', |
|
| 1281 | + 'pgsql', |
|
| 1282 | + 'oci', |
|
| 1283 | 1283 | ), |
| 1284 | 1284 | |
| 1285 | 1285 | /** |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * ubos-raspberry-pi.local and ubos-raspberry-pi-2.local |
| 68 | 68 | */ |
| 69 | 69 | 'trusted_domains' => |
| 70 | - array ( |
|
| 70 | + array( |
|
| 71 | 71 | 'demo.example.org', |
| 72 | 72 | 'otherdomain.example.org', |
| 73 | 73 | ), |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * |
| 193 | 193 | * Defaults to ``60*60*24*15`` seconds (15 days) |
| 194 | 194 | */ |
| 195 | -'remember_login_cookie_lifetime' => 60*60*24*15, |
|
| 195 | +'remember_login_cookie_lifetime' => 60 * 60 * 24 * 15, |
|
| 196 | 196 | |
| 197 | 197 | /** |
| 198 | 198 | * The lifetime of a session after inactivity. |
@@ -1070,7 +1070,7 @@ discard block |
||
| 1070 | 1070 | * - \RedisCluster::FAILOVER_DISTRIBUTE - randomly distribute read commands across master and slaves |
| 1071 | 1071 | */ |
| 1072 | 1072 | 'redis.cluster' => [ |
| 1073 | - 'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required |
|
| 1073 | + 'seeds' => [// provide some/all of the cluster servers to bootstrap discovery, port required |
|
| 1074 | 1074 | 'localhost:7000', |
| 1075 | 1075 | 'localhost:7001' |
| 1076 | 1076 | ], |
@@ -1134,7 +1134,7 @@ discard block |
||
| 1134 | 1134 | * |
| 1135 | 1135 | * Defaults to ``60*60*24`` (1 day) |
| 1136 | 1136 | */ |
| 1137 | -'cache_chunk_gc_ttl' => 60*60*24, |
|
| 1137 | +'cache_chunk_gc_ttl' => 60 * 60 * 24, |
|
| 1138 | 1138 | |
| 1139 | 1139 | /** |
| 1140 | 1140 | * Using Object Store with Nextcloud |
@@ -1453,7 +1453,7 @@ discard block |
||
| 1453 | 1453 | * Defaults to ``60*60`` seconds (1 hour) or the php |
| 1454 | 1454 | * max_execution_time, whichever is higher. |
| 1455 | 1455 | */ |
| 1456 | -'filelocking.ttl' => 60*60, |
|
| 1456 | +'filelocking.ttl' => 60 * 60, |
|
| 1457 | 1457 | |
| 1458 | 1458 | /** |
| 1459 | 1459 | * Memory caching backend for file locking |