@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function getCreationDate() |
113 | 113 | { |
114 | - if ($this->driver->getConfig()[ 'itemDetailedDate' ]) { |
|
114 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
115 | 115 | return $this->creationDate; |
116 | 116 | } else { |
117 | 117 | throw new phpFastCacheLogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function setCreationDate(\DateTimeInterface $date) |
127 | 127 | { |
128 | - if ($this->driver->getConfig()[ 'itemDetailedDate' ]) { |
|
128 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
129 | 129 | $this->creationDate = $date; |
130 | 130 | return $this; |
131 | 131 | } else { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function getModificationDate() |
141 | 141 | { |
142 | - if ($this->driver->getConfig()[ 'itemDetailedDate' ]) { |
|
142 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
143 | 143 | return $this->modificationDate; |
144 | 144 | } else { |
145 | 145 | throw new phpFastCacheLogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.'); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function setModificationDate(\DateTimeInterface $date) |
155 | 155 | { |
156 | - if ($this->driver->getConfig()[ 'itemDetailedDate' ]) { |
|
156 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
157 | 157 | $this->modificationDate = $date; |
158 | 158 | return $this; |
159 | 159 | } else { |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | if (is_array($this->data)) { |
227 | 227 | $this->data[] = $data; |
228 | 228 | } else if (is_string($data)) { |
229 | - $this->data .= (string)$data; |
|
229 | + $this->data .= (string) $data; |
|
230 | 230 | } else { |
231 | 231 | throw new phpFastCacheInvalidArgumentException('$data must be either array nor string.'); |
232 | 232 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | if (is_array($this->data)) { |
246 | 246 | array_unshift($this->data, $data); |
247 | 247 | } else if (is_string($data)) { |
248 | - $this->data = (string)$data . $this->data; |
|
248 | + $this->data = (string) $data . $this->data; |
|
249 | 249 | } else { |
250 | 250 | throw new phpFastCacheInvalidArgumentException('$data must be either array nor string.'); |
251 | 251 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | public function removeTag($tagName) |
325 | 325 | { |
326 | 326 | if (($key = array_search($tagName, $this->tags)) !== false) { |
327 | - unset($this->tags[ $key ]); |
|
327 | + unset($this->tags[$key]); |
|
328 | 328 | $this->removedTags[] = $tagName; |
329 | 329 | } |
330 | 330 | |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | final public function __debugInfo() |
404 | 404 | { |
405 | 405 | $info = get_object_vars($this); |
406 | - $info[ 'driver' ] = 'object(' . get_class($info[ 'driver' ]) . ')'; |
|
406 | + $info['driver'] = 'object(' . get_class($info['driver']) . ')'; |
|
407 | 407 | |
408 | - return (array)$info; |
|
408 | + return (array) $info; |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | \ No newline at end of file |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function __construct() |
38 | 38 | { |
39 | - $this->instances =& CacheManager::getInternalInstances(); |
|
39 | + $this->instances = & CacheManager::getInternalInstances(); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected function getGenericCallback() |
46 | 46 | { |
47 | - return function ($method, $args) { |
|
47 | + return function($method, $args) { |
|
48 | 48 | $getterMethod = (strpos($method, 'get') === 0); |
49 | 49 | $return = false; |
50 | 50 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | foreach ($this->instances as $instance) { |
56 | 56 | $reflectionMethod = new \ReflectionMethod(get_class($instance), $method); |
57 | 57 | if ($getterMethod) { |
58 | - $return[ $instance->getDriverName() ] = $reflectionMethod->invokeArgs($instance, $args); |
|
58 | + $return[$instance->getDriverName()] = $reflectionMethod->invokeArgs($instance, $args); |
|
59 | 59 | } else { |
60 | 60 | $result = $reflectionMethod->invokeArgs($instance, $args); |
61 | 61 | if ($result !== false) { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $keyword = self::PREFIX . $item->getKey(); |
82 | 82 | $v = json_encode($this->driverPreWrap($item)); |
83 | 83 | |
84 | - if (isset($this->config[ 'limited_memory_each_object' ]) && strlen($v) > $this->config[ 'limited_memory_each_object' ]) { |
|
84 | + if (isset($this->config['limited_memory_each_object']) && strlen($v) > $this->config['limited_memory_each_object']) { |
|
85 | 85 | return false; |
86 | 86 | } |
87 | 87 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | { |
101 | 101 | $this->driverConnect(); |
102 | 102 | $keyword = self::PREFIX . $item->getKey(); |
103 | - $x = isset($_COOKIE[ $keyword ]) ? json_decode($_COOKIE[ $keyword ], true) : false; |
|
103 | + $x = isset($_COOKIE[$keyword]) ? json_decode($_COOKIE[$keyword], true) : false; |
|
104 | 104 | |
105 | 105 | if ($x == false) { |
106 | 106 | return null; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | { |
122 | 122 | $this->driverConnect(); |
123 | 123 | $keyword = self::PREFIX . $key; |
124 | - $x = isset($_COOKIE[ $keyword ]) ? $this->decode(json_decode($_COOKIE[ $keyword ])->t) : false; |
|
124 | + $x = isset($_COOKIE[$keyword]) ? $this->decode(json_decode($_COOKIE[$keyword])->t) : false; |
|
125 | 125 | |
126 | 126 | return $x ? $x - time() : $x; |
127 | 127 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | if ($item instanceof Item) { |
140 | 140 | $this->driverConnect(); |
141 | 141 | $keyword = self::PREFIX . $item->getKey(); |
142 | - $_COOKIE[ $keyword ] = null; |
|
142 | + $_COOKIE[$keyword] = null; |
|
143 | 143 | |
144 | 144 | return @setcookie($keyword, null, -10); |
145 | 145 | } else { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $this->driverConnect(); |
157 | 157 | foreach ($_COOKIE as $keyword => $value) { |
158 | 158 | if (strpos($keyword, self::PREFIX) !== false) { |
159 | - $_COOKIE[ $keyword ] = null; |
|
159 | + $_COOKIE[$keyword] = null; |
|
160 | 160 | $result = @setcookie($keyword, null, -10); |
161 | 161 | if ($return !== false) { |
162 | 162 | $return = $result; |
@@ -62,7 +62,7 @@ |
||
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @param \Psr\Cache\CacheItemInterface $item |
65 | - * @return mixed |
|
65 | + * @return boolean |
|
66 | 66 | * @throws phpFastCacheInvalidArgumentException |
67 | 67 | */ |
68 | 68 | protected function driverWrite(CacheItemInterface $item) |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : NULL; |
149 | 149 | $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : NULL; |
150 | 150 | $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
151 | - [ |
|
151 | + [ |
|
152 | 152 | 'bucket' => 'default', |
153 | - ], |
|
153 | + ], |
|
154 | 154 | ]; |
155 | 155 | |
156 | 156 | // Establish username and password for bucket access |
@@ -213,10 +213,10 @@ discard block |
||
213 | 213 | $info = $this->getBucket()->manager()->info(); |
214 | 214 | |
215 | 215 | return (new DriverStatistic()) |
216 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
217 | - ->setRawData($info) |
|
218 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
219 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, |
|
220 | - 1) . "\n For more information see RawData."); |
|
216 | + ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
217 | + ->setRawData($info) |
|
218 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
219 | + ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, |
|
220 | + 1) . "\n For more information see RawData."); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | \ No newline at end of file |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | if ($item instanceof Item) { |
81 | 81 | try { |
82 | - return (bool)$this->getBucket()->upsert($item->getEncodedKey(), $this->encode($this->driverPreWrap($item)), ['expiry' => $item->getTtl()]); |
|
82 | + return (bool) $this->getBucket()->upsert($item->getEncodedKey(), $this->encode($this->driverPreWrap($item)), ['expiry' => $item->getTtl()]); |
|
83 | 83 | } catch (\CouchbaseException $e) { |
84 | 84 | return false; |
85 | 85 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | if ($item instanceof Item) { |
118 | 118 | try { |
119 | - return (bool)$this->getBucket()->remove($item->getEncodedKey()); |
|
119 | + return (bool) $this->getBucket()->remove($item->getEncodedKey()); |
|
120 | 120 | } catch (\Couchbase\Exception $e) { |
121 | 121 | return $e->getCode() === COUCHBASE_KEY_ENOENT; |
122 | 122 | } |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | throw new phpFastCacheLogicException('Already connected to Couchbase server'); |
144 | 144 | } else { |
145 | 145 | |
146 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
147 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : NULL; |
|
148 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : NULL; |
|
149 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : NULL; |
|
150 | - $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
|
146 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
147 | + $port = isset($this->config['port']) ? $this->config['port'] : NULL; |
|
148 | + $password = isset($this->config['password']) ? $this->config['password'] : NULL; |
|
149 | + $username = isset($this->config['username']) ? $this->config['username'] : NULL; |
|
150 | + $buckets = isset($this->config['buckets']) ? $this->config['buckets'] : [ |
|
151 | 151 | [ |
152 | 152 | 'bucket' => 'default', |
153 | 153 | ], |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | |
156 | 156 | // Establish username and password for bucket access |
157 | 157 | $authenticator = new \Couchbase\PasswordAuthenticator(); |
158 | - $authenticator->username($this->config[ 'username' ])->password($this->config[ 'password' ]); |
|
158 | + $authenticator->username($this->config['username'])->password($this->config['password']); |
|
159 | 159 | |
160 | 160 | // Connect to Couchbase Server |
161 | 161 | if (isset($port)) { |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | $this->instance = $this->instance ?: $cluster; |
170 | 170 | |
171 | 171 | foreach ($buckets as $bucket) { |
172 | - $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ]; |
|
173 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ])); |
|
172 | + $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket']; |
|
173 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'])); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | protected function getBucket() |
184 | 184 | { |
185 | - return $this->bucketInstances[ $this->bucketCurrent ]; |
|
185 | + return $this->bucketInstances[$this->bucketCurrent]; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | protected function setBucket($bucketName, \CouchbaseBucket $CouchbaseBucket) |
194 | 194 | { |
195 | 195 | if (!array_key_exists($bucketName, $this->bucketInstances)) { |
196 | - $this->bucketInstances[ $bucketName ] = $CouchbaseBucket; |
|
196 | + $this->bucketInstances[$bucketName] = $CouchbaseBucket; |
|
197 | 197 | } else { |
198 | 198 | throw new phpFastCacheLogicException('A bucket instance with this name already exists.'); |
199 | 199 | } |
@@ -213,10 +213,10 @@ discard block |
||
213 | 213 | $info = $this->getBucket()->manager()->info(); |
214 | 214 | |
215 | 215 | return (new DriverStatistic()) |
216 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
216 | + ->setSize($info['basicStats']['diskUsed']) |
|
217 | 217 | ->setRawData($info) |
218 | 218 | ->setData(implode(', ', array_keys($this->itemInstances))) |
219 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, |
|
219 | + ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, |
|
220 | 220 | 1) . "\n For more information see RawData."); |
221 | 221 | } |
222 | 222 | } |
223 | 223 | \ No newline at end of file |
@@ -23,6 +23,7 @@ |
||
23 | 23 | { |
24 | 24 | /** |
25 | 25 | * @inheritdoc |
26 | + * @param phpFastCacheIOException $previous |
|
26 | 27 | */ |
27 | 28 | public function __construct($message = "", $code = 0, $previous = null) |
28 | 29 | { |
@@ -27,7 +27,7 @@ |
||
27 | 27 | public function __construct($message = "", $code = 0, $previous = null) |
28 | 28 | { |
29 | 29 | $lastError = error_get_last(); |
30 | - if($lastError){ |
|
30 | + if ($lastError) { |
|
31 | 31 | $message .= "\n"; |
32 | 32 | $message .= "Additional information provided by error_get_last():\n"; |
33 | 33 | $message .= "{$lastError['message']} in {$lastError['file']} line {$lastError['line']}"; |
@@ -152,7 +152,7 @@ |
||
152 | 152 | */ |
153 | 153 | if(!empty($server[ 'path' ]) && !$this->instance->addServer($server[ 'path' ], 0)){ |
154 | 154 | $this->fallback = true; |
155 | - }else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
155 | + } else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
156 | 156 | $this->fallback = true; |
157 | 157 | } |
158 | 158 |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
136 | 136 | if (count($servers) < 1) { |
137 | 137 | $servers = [ |
138 | - [ |
|
138 | + [ |
|
139 | 139 | 'host' => !empty($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1', |
140 | 140 | 'path' => !empty($this->config[ 'path' ]) ? $this->config[ 'path' ] : false, |
141 | 141 | 'port' => !empty($this->config[ 'port' ]) ? $this->config[ 'port' ] : 11211, |
142 | 142 | 'sasl_user' => !empty($this->config[ 'sasl_user' ]) ? $this->config[ 'sasl_user' ] : false, |
143 | 143 | 'sasl_password' =>!empty($this->config[ 'sasl_password' ]) ? $this->config[ 'sasl_password' ]: false, |
144 | - ], |
|
144 | + ], |
|
145 | 145 | ]; |
146 | 146 | } |
147 | 147 | |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
196 | 196 | |
197 | 197 | return (new DriverStatistic()) |
198 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
199 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
200 | - ->setRawData($stats) |
|
201 | - ->setSize($stats[ 'bytes' ]); |
|
198 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
199 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
200 | + ->setRawData($stats) |
|
201 | + ->setSize($stats[ 'bytes' ]); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | \ No newline at end of file |
@@ -132,15 +132,15 @@ discard block |
||
132 | 132 | { |
133 | 133 | $this->instance = new MemcachedSoftware(); |
134 | 134 | $this->instance->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); |
135 | - $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
|
135 | + $servers = (!empty($this->config['servers']) && is_array($this->config['servers']) ? $this->config['servers'] : []); |
|
136 | 136 | if (count($servers) < 1) { |
137 | 137 | $servers = [ |
138 | 138 | [ |
139 | - 'host' => !empty($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1', |
|
140 | - 'path' => !empty($this->config[ 'path' ]) ? $this->config[ 'path' ] : false, |
|
141 | - 'port' => !empty($this->config[ 'port' ]) ? $this->config[ 'port' ] : 11211, |
|
142 | - 'sasl_user' => !empty($this->config[ 'sasl_user' ]) ? $this->config[ 'sasl_user' ] : false, |
|
143 | - 'sasl_password' =>!empty($this->config[ 'sasl_password' ]) ? $this->config[ 'sasl_password' ]: false, |
|
139 | + 'host' => !empty($this->config['host']) ? $this->config['host'] : '127.0.0.1', |
|
140 | + 'path' => !empty($this->config['path']) ? $this->config['path'] : false, |
|
141 | + 'port' => !empty($this->config['port']) ? $this->config['port'] : 11211, |
|
142 | + 'sasl_user' => !empty($this->config['sasl_user']) ? $this->config['sasl_user'] : false, |
|
143 | + 'sasl_password' =>!empty($this->config['sasl_password']) ? $this->config['sasl_password'] : false, |
|
144 | 144 | ], |
145 | 145 | ]; |
146 | 146 | } |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | /** |
151 | 151 | * If path is provided we consider it as an UNIX Socket |
152 | 152 | */ |
153 | - if(!empty($server[ 'path' ]) && !$this->instance->addServer($server[ 'path' ], 0)){ |
|
153 | + if (!empty($server['path']) && !$this->instance->addServer($server['path'], 0)) { |
|
154 | 154 | $this->fallback = true; |
155 | - }else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
155 | + } else if (!empty($server['host']) && !$this->instance->addServer($server['host'], $server['port'])) { |
|
156 | 156 | $this->fallback = true; |
157 | 157 | } |
158 | 158 | |
159 | - if (!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password' ])) { |
|
160 | - $this->instance->setSaslAuthData($server[ 'sasl_user' ], $server[ 'sasl_password' ]); |
|
159 | + if (!empty($server['sasl_user']) && !empty($server['sasl_password'])) { |
|
160 | + $this->instance->setSaslAuthData($server['sasl_user'], $server['sasl_password']); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | } catch (\Exception $e) { |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * any error if not connected ... |
171 | 171 | */ |
172 | 172 | $version = $this->instance->getVersion(); |
173 | - if(!$version || $this->instance->getResultCode() !== MemcachedSoftware::RES_SUCCESS){ |
|
173 | + if (!$version || $this->instance->getResultCode() !== MemcachedSoftware::RES_SUCCESS) { |
|
174 | 174 | throw new phpFastCacheDriverException('Memcached seems to not be connected'); |
175 | 175 | } |
176 | 176 | return true; |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | public function getStats() |
189 | 189 | { |
190 | 190 | $stats = current($this->instance->getStats()); |
191 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
192 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : $this->instance->getVersion()); |
|
193 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
191 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
192 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : $this->instance->getVersion()); |
|
193 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
194 | 194 | |
195 | - $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
195 | + $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
|
196 | 196 | |
197 | 197 | return (new DriverStatistic()) |
198 | 198 | ->setData(implode(', ', array_keys($this->itemInstances))) |
199 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
199 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
200 | 200 | ->setRawData($stats) |
201 | - ->setSize($stats[ 'bytes' ]); |
|
201 | + ->setSize($stats['bytes']); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | \ No newline at end of file |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | $path = isset($config[ 'path' ]) ? (string) $config[ 'path' ] : false; |
139 | 139 | |
140 | 140 | $defaultConfig = [ |
141 | - 'host' => '127.0.0.1', |
|
142 | - 'port' => 6379, |
|
143 | - 'password' => null, |
|
144 | - 'database' => null, |
|
141 | + 'host' => '127.0.0.1', |
|
142 | + 'port' => 6379, |
|
143 | + 'password' => null, |
|
144 | + 'database' => null, |
|
145 | 145 | ]; |
146 | 146 | $config = array_merge($defaultConfig, $config); |
147 | 147 | |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | */ |
151 | 151 | if($path){ |
152 | 152 | $this->instance = new PredisClient([ |
153 | - 'scheme' => 'unix', |
|
154 | - 'path' => $path |
|
153 | + 'scheme' => 'unix', |
|
154 | + 'path' => $path |
|
155 | 155 | ]); |
156 | 156 | }else{ |
157 | 157 | $this->instance = new PredisClient($config); |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date'); |
198 | 198 | |
199 | 199 | return (new DriverStatistic()) |
200 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
201 | - ->setRawData($info) |
|
202 | - ->setSize($size) |
|
203 | - ->setInfo(sprintf("The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", |
|
200 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
201 | + ->setRawData($info) |
|
202 | + ->setSize($size) |
|
203 | + ->setInfo(sprintf("The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", |
|
204 | 204 | $version, $date->format(DATE_RFC2822))); |
205 | 205 | } |
206 | 206 | } |
207 | 207 | \ No newline at end of file |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * @see https://redis.io/commands/setex |
79 | 79 | * @see https://redis.io/commands/expire |
80 | 80 | */ |
81 | - if($ttl <= 0){ |
|
81 | + if ($ttl <= 0) { |
|
82 | 82 | return $this->instance->expire($item->getKey(), 0); |
83 | - }else{ |
|
83 | + } else { |
|
84 | 84 | return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item))); |
85 | 85 | } |
86 | 86 | } else { |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | protected function driverConnect() |
135 | 135 | { |
136 | 136 | /** Backward compatibility */ |
137 | - $config = isset($this->config[ 'predis' ]) ? $this->config[ 'predis' ] : $this->config; |
|
138 | - $path = isset($config[ 'path' ]) ? (string) $config[ 'path' ] : false; |
|
137 | + $config = isset($this->config['predis']) ? $this->config['predis'] : $this->config; |
|
138 | + $path = isset($config['path']) ? (string) $config['path'] : false; |
|
139 | 139 | |
140 | 140 | $defaultConfig = [ |
141 | 141 | 'host' => '127.0.0.1', |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | /** |
149 | 149 | * If path is provided we consider it as an UNIX Socket |
150 | 150 | */ |
151 | - if($path){ |
|
151 | + if ($path) { |
|
152 | 152 | $this->instance = new PredisClient([ |
153 | 153 | 'scheme' => 'unix', |
154 | 154 | 'path' => $path |
155 | 155 | ]); |
156 | - }else{ |
|
156 | + } else { |
|
157 | 157 | $this->instance = new PredisClient($config); |
158 | 158 | } |
159 | 159 | |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | public function getStats() |
193 | 193 | { |
194 | 194 | $info = $this->instance->info(); |
195 | - $size = (isset($info[ 'Memory' ][ 'used_memory' ]) ? $info[ 'Memory' ][ 'used_memory' ] : 0); |
|
196 | - $version = (isset($info[ 'Server' ][ 'redis_version' ]) ? $info[ 'Server' ][ 'redis_version' ] : 0); |
|
197 | - $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date'); |
|
195 | + $size = (isset($info['Memory']['used_memory']) ? $info['Memory']['used_memory'] : 0); |
|
196 | + $version = (isset($info['Server']['redis_version']) ? $info['Server']['redis_version'] : 0); |
|
197 | + $date = (isset($info['Server']['uptime_in_seconds']) ? (new \DateTime())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
198 | 198 | |
199 | 199 | return (new DriverStatistic()) |
200 | 200 | ->setData(implode(', ', array_keys($this->itemInstances))) |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | if($ttl <= 0){ |
82 | 82 | return $this->instance->expire($item->getKey(), 0); |
83 | - }else{ |
|
83 | + } else{ |
|
84 | 84 | return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item))); |
85 | 85 | } |
86 | 86 | } else { |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'scheme' => 'unix', |
154 | 154 | 'path' => $path |
155 | 155 | ]); |
156 | - }else{ |
|
156 | + } else{ |
|
157 | 157 | $this->instance = new PredisClient($config); |
158 | 158 | } |
159 | 159 |
@@ -152,7 +152,7 @@ |
||
152 | 152 | */ |
153 | 153 | if(!empty($server[ 'path' ]) && !$this->instance->addServer($server[ 'path' ], 0)){ |
154 | 154 | $this->fallback = true; |
155 | - }else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
155 | + } else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
156 | 156 | $this->fallback = true; |
157 | 157 | } |
158 | 158 |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
136 | 136 | if (count($servers) < 1) { |
137 | 137 | $servers = [ |
138 | - [ |
|
138 | + [ |
|
139 | 139 | 'host' => !empty($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1', |
140 | 140 | 'path' => !empty($this->config[ 'path' ]) ? $this->config[ 'path' ] : false, |
141 | 141 | 'port' => !empty($this->config[ 'port' ]) ? $this->config[ 'port' ] : 11211, |
142 | 142 | 'sasl_user' => !empty($this->config[ 'sasl_user' ]) ? $this->config[ 'sasl_user' ] : false, |
143 | 143 | 'sasl_password' =>!empty($this->config[ 'sasl_password' ]) ? $this->config[ 'sasl_password' ]: false, |
144 | - ], |
|
144 | + ], |
|
145 | 145 | ]; |
146 | 146 | } |
147 | 147 | |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
196 | 196 | |
197 | 197 | return (new DriverStatistic()) |
198 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
199 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
200 | - ->setRawData($stats) |
|
201 | - ->setSize($stats[ 'bytes' ]); |
|
198 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
199 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
200 | + ->setRawData($stats) |
|
201 | + ->setSize($stats[ 'bytes' ]); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | \ No newline at end of file |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | } else { |
54 | 54 | $this->driverConnect(); |
55 | 55 | |
56 | - if (array_key_exists('compress_data', $config) && $config[ 'compress_data' ] === true) { |
|
56 | + if (array_key_exists('compress_data', $config) && $config['compress_data'] === true) { |
|
57 | 57 | $this->memcacheFlags = MEMCACHE_COMPRESSED; |
58 | 58 | } |
59 | 59 | } |
@@ -138,15 +138,15 @@ discard block |
||
138 | 138 | protected function driverConnect() |
139 | 139 | { |
140 | 140 | $this->instance = new MemcacheSoftware(); |
141 | - $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
|
141 | + $servers = (!empty($this->config['servers']) && is_array($this->config['servers']) ? $this->config['servers'] : []); |
|
142 | 142 | if (count($servers) < 1) { |
143 | 143 | $servers = [ |
144 | 144 | [ |
145 | - 'host' => !empty($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1', |
|
146 | - 'path' => !empty($this->config[ 'path' ]) ? $this->config[ 'path' ] : false, |
|
147 | - 'port' => !empty($this->config[ 'port' ]) ? $this->config[ 'port' ] : 11211, |
|
148 | - 'sasl_user' => !empty($this->config[ 'sasl_user' ]) ? $this->config[ 'sasl_user' ] : false, |
|
149 | - 'sasl_password' =>!empty($this->config[ 'sasl_password' ]) ? $this->config[ 'sasl_password' ]: false, |
|
145 | + 'host' => !empty($this->config['host']) ? $this->config['host'] : '127.0.0.1', |
|
146 | + 'path' => !empty($this->config['path']) ? $this->config['path'] : false, |
|
147 | + 'port' => !empty($this->config['port']) ? $this->config['port'] : 11211, |
|
148 | + 'sasl_user' => !empty($this->config['sasl_user']) ? $this->config['sasl_user'] : false, |
|
149 | + 'sasl_password' =>!empty($this->config['sasl_password']) ? $this->config['sasl_password'] : false, |
|
150 | 150 | ], |
151 | 151 | ]; |
152 | 152 | } |
@@ -156,13 +156,13 @@ discard block |
||
156 | 156 | /** |
157 | 157 | * If path is provided we consider it as an UNIX Socket |
158 | 158 | */ |
159 | - if(!empty($server[ 'path' ]) && !$this->instance->addServer($server[ 'path' ], 0)){ |
|
159 | + if (!empty($server['path']) && !$this->instance->addServer($server['path'], 0)) { |
|
160 | 160 | $this->fallback = true; |
161 | - }else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
161 | + } else if (!empty($server['host']) && !$this->instance->addServer($server['host'], $server['port'])) { |
|
162 | 162 | $this->fallback = true; |
163 | 163 | } |
164 | 164 | |
165 | - if (!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password' ])) { |
|
165 | + if (!empty($server['sasl_user']) && !empty($server['sasl_password'])) { |
|
166 | 166 | throw new phpFastCacheDriverException('Unlike Memcached, Memcache does not support SASL authentication'); |
167 | 167 | } |
168 | 168 | } catch (\Exception $e) { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * Since Memcached does not throw |
174 | 174 | * any error if not connected ... |
175 | 175 | */ |
176 | - if(!$this->instance->getServerStatus(!empty($server[ 'path' ]) ? $server[ 'path' ] : $server[ 'host' ], !empty($server[ 'port' ]) ? $server[ 'port' ] : 0)){ |
|
176 | + if (!$this->instance->getServerStatus(!empty($server['path']) ? $server['path'] : $server['host'], !empty($server['port']) ? $server['port'] : 0)) { |
|
177 | 177 | throw new phpFastCacheDriverException('Memcache seems to not be connected'); |
178 | 178 | } |
179 | 179 | } |
@@ -192,17 +192,17 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function getStats() |
194 | 194 | { |
195 | - $stats = (array)$this->instance->getstats(); |
|
196 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
197 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion'); |
|
198 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
195 | + $stats = (array) $this->instance->getstats(); |
|
196 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
197 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion'); |
|
198 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
199 | 199 | |
200 | - $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
200 | + $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
|
201 | 201 | |
202 | 202 | return (new DriverStatistic()) |
203 | 203 | ->setData(implode(', ', array_keys($this->itemInstances))) |
204 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
204 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
205 | 205 | ->setRawData($stats) |
206 | - ->setSize($stats[ 'bytes' ]); |
|
206 | + ->setSize($stats['bytes']); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | \ No newline at end of file |