@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @param \Psr\Cache\CacheItemInterface $item |
56 | - * @return mixed |
|
56 | + * @return boolean |
|
57 | 57 | * @throws \InvalidArgumentException |
58 | 58 | */ |
59 | 59 | public function driverWrite(CacheItemInterface $item) |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | /** |
114 | 114 | * @param \Psr\Cache\CacheItemInterface $item |
115 | - * @return bool |
|
115 | + * @return boolean|null |
|
116 | 116 | * @throws \InvalidArgumentException |
117 | 117 | */ |
118 | 118 | public function driverIsHit(CacheItemInterface $item) |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | if ($item instanceof Item) { |
79 | 79 | try { |
80 | 80 | $result = (array) $this->getCollection()->update( |
81 | - ['_id' => $item->getKey()], |
|
82 | - [ |
|
81 | + ['_id' => $item->getKey()], |
|
82 | + [ |
|
83 | 83 | '$set' => [ |
84 | - self::DRIVER_TIME_WRAPPER_INDEX => ($item->getTtl() > 0 ? new MongoDate(time() + $item->getTtl()) : new MongoDate(time())), |
|
85 | - self::DRIVER_DATA_WRAPPER_INDEX => new MongoBinData($this->encode($item->get()), MongoBinData::BYTE_ARRAY), |
|
86 | - self::DRIVER_TAGS_WRAPPER_INDEX => new MongoBinData($this->encode($item->getTags()), MongoBinData::BYTE_ARRAY), |
|
84 | + self::DRIVER_TIME_WRAPPER_INDEX => ($item->getTtl() > 0 ? new MongoDate(time() + $item->getTtl()) : new MongoDate(time())), |
|
85 | + self::DRIVER_DATA_WRAPPER_INDEX => new MongoBinData($this->encode($item->get()), MongoBinData::BYTE_ARRAY), |
|
86 | + self::DRIVER_TAGS_WRAPPER_INDEX => new MongoBinData($this->encode($item->getTags()), MongoBinData::BYTE_ARRAY), |
|
87 | 87 | ], |
88 | - ], |
|
89 | - ['upsert' => true, 'multiple' => false] |
|
88 | + ], |
|
89 | + ['upsert' => true, 'multiple' => false] |
|
90 | 90 | ); |
91 | 91 | } catch (MongoCursorException $e) { |
92 | 92 | return false; |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | protected function driverRead(CacheItemInterface $item) |
106 | 106 | { |
107 | 107 | $document = $this->getCollection() |
108 | - ->findOne(['_id' => $item->getKey()], |
|
108 | + ->findOne(['_id' => $item->getKey()], |
|
109 | 109 | [self::DRIVER_DATA_WRAPPER_INDEX, self::DRIVER_TIME_WRAPPER_INDEX, self::DRIVER_TAGS_WRAPPER_INDEX /*'d', 'e'*/]); |
110 | 110 | |
111 | 111 | if ($document) { |
112 | 112 | return [ |
113 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
114 | - self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
115 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
113 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
114 | + self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
115 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
116 | 116 | ]; |
117 | 117 | } else { |
118 | 118 | return null; |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | * @todo make an url builder |
168 | 168 | */ |
169 | 169 | $this->instance = $this->instance ?: (new MongodbClient('mongodb://' . |
170 | - ($username ?: '') . |
|
171 | - ($password ? ":{$password}" : '') . |
|
172 | - ($username ? '@' : '') . "{$host}" . |
|
173 | - ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]))->phpFastCache; |
|
170 | + ($username ?: '') . |
|
171 | + ($password ? ":{$password}" : '') . |
|
172 | + ($username ? '@' : '') . "{$host}" . |
|
173 | + ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]))->phpFastCache; |
|
174 | 174 | // $this->instance->Cache->createIndex([self::DRIVER_TIME_WRAPPER_INDEX => 1], ['expireAfterSeconds' => 0]); |
175 | 175 | } |
176 | 176 | } |
@@ -196,25 +196,25 @@ discard block |
||
196 | 196 | public function getStats() |
197 | 197 | { |
198 | 198 | $serverStatus = $this->getCollection()->db->command([ |
199 | - 'serverStatus' => 1, |
|
200 | - 'recordStats' => 0, |
|
201 | - 'repl' => 0, |
|
202 | - 'metrics' => 0, |
|
199 | + 'serverStatus' => 1, |
|
200 | + 'recordStats' => 0, |
|
201 | + 'repl' => 0, |
|
202 | + 'metrics' => 0, |
|
203 | 203 | ]); |
204 | 204 | |
205 | 205 | $collStats = $this->getCollection()->db->command([ |
206 | - 'collStats' => 'Cache', |
|
207 | - 'verbose' => true, |
|
206 | + 'collStats' => 'Cache', |
|
207 | + 'verbose' => true, |
|
208 | 208 | ]); |
209 | 209 | |
210 | 210 | $stats = (new driverStatistic()) |
211 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
212 | - ->setSize((int) @$collStats[ 'size' ]) |
|
213 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
214 | - ->setRawData([ |
|
211 | + ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
212 | + ->setSize((int) @$collStats[ 'size' ]) |
|
213 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
214 | + ->setRawData([ |
|
215 | 215 | 'serverStatus' => $serverStatus, |
216 | 216 | 'collStats' => $collStats, |
217 | - ]); |
|
217 | + ]); |
|
218 | 218 | |
219 | 219 | return $stats; |
220 | 220 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function driverCheck() |
61 | 61 | { |
62 | - if(class_exists('MongoDB\Driver\Manager')){ |
|
62 | + if (class_exists('MongoDB\Driver\Manager')) { |
|
63 | 63 | trigger_error('PhpFastCache currently only support the pecl Mongo extension.<br /> |
64 | 64 | The Support for the MongoDB extension will be added coming soon.', E_USER_ERROR); |
65 | 65 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | return false; |
95 | 95 | } |
96 | 96 | |
97 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
97 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
98 | 98 | } else { |
99 | 99 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
100 | 100 | } |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | |
113 | 113 | if ($document) { |
114 | 114 | return [ |
115 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
116 | - self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
117 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
115 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->bin), |
|
116 | + self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_TIME_WRAPPER_INDEX]->sec), |
|
117 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->bin), |
|
118 | 118 | ]; |
119 | 119 | } else { |
120 | 120 | return null; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | if ($item instanceof Item) { |
135 | 135 | $deletionResult = (array) $this->getCollection()->remove(['_id' => $item->getKey()], ["w" => 1]); |
136 | 136 | |
137 | - return (int) $deletionResult[ 'ok' ] === 1 && !$deletionResult[ 'err' ]; |
|
137 | + return (int) $deletionResult['ok'] === 1 && !$deletionResult['err']; |
|
138 | 138 | } else { |
139 | 139 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
140 | 140 | } |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | if ($this->instance instanceof MongodbClient) { |
159 | 159 | throw new LogicException('Already connected to Mongodb server'); |
160 | 160 | } else { |
161 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
162 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : '27017'; |
|
163 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 3; |
|
164 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
165 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
161 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
162 | + $port = isset($this->config['port']) ? $this->config['port'] : '27017'; |
|
163 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 3; |
|
164 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
165 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
166 | 166 | |
167 | 167 | |
168 | 168 | /** |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | ]); |
211 | 211 | |
212 | 212 | $stats = (new driverStatistic()) |
213 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
214 | - ->setSize((int) @$collStats[ 'size' ]) |
|
213 | + ->setInfo('MongoDB version ' . $serverStatus['version'] . ', Uptime (in days): ' . round($serverStatus['uptime'] / 86400, 1) . "\n For more information see RawData.") |
|
214 | + ->setSize((int) @$collStats['size']) |
|
215 | 215 | ->setData(implode(', ', array_keys($this->itemInstances))) |
216 | 216 | ->setRawData([ |
217 | 217 | 'serverStatus' => $serverStatus, |
@@ -159,9 +159,9 @@ |
||
159 | 159 | $date = (new \DateTime())->setTimestamp(time() - $info[ 'uptime_in_seconds' ]); |
160 | 160 | |
161 | 161 | return (new driverStatistic()) |
162 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
163 | - ->setRawData($info) |
|
164 | - ->setSize($info[ 'used_memory' ]) |
|
165 | - ->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.", $info[ 'redis_version' ], $date->format(DATE_RFC2822))); |
|
162 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
163 | + ->setRawData($info) |
|
164 | + ->setSize($info[ 'used_memory' ]) |
|
165 | + ->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.", $info[ 'redis_version' ], $date->format(DATE_RFC2822))); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | \ No newline at end of file |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | } else { |
123 | 123 | $this->instance = $this->instance ?: new RedisClient(); |
124 | 124 | |
125 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
126 | - $port = isset($this->config[ 'port' ]) ? (int) $this->config[ 'port' ] : '6379'; |
|
127 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
128 | - $database = isset($this->config[ 'database' ]) ? $this->config[ 'database' ] : ''; |
|
129 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : ''; |
|
125 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
126 | + $port = isset($this->config['port']) ? (int) $this->config['port'] : '6379'; |
|
127 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
128 | + $database = isset($this->config['database']) ? $this->config['database'] : ''; |
|
129 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : ''; |
|
130 | 130 | |
131 | 131 | if (!$this->instance->connect($host, (int) $port, (int) $timeout)) { |
132 | 132 | return false; |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | { |
157 | 157 | // used_memory |
158 | 158 | $info = $this->instance->info(); |
159 | - $date = (new \DateTime())->setTimestamp(time() - $info[ 'uptime_in_seconds' ]); |
|
159 | + $date = (new \DateTime())->setTimestamp(time() - $info['uptime_in_seconds']); |
|
160 | 160 | |
161 | 161 | return (new driverStatistic()) |
162 | 162 | ->setData(implode(', ', array_keys($this->itemInstances))) |
163 | 163 | ->setRawData($info) |
164 | - ->setSize($info[ 'used_memory' ]) |
|
165 | - ->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.", $info[ 'redis_version' ], $date->format(DATE_RFC2822))); |
|
164 | + ->setSize($info['used_memory']) |
|
165 | + ->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.", $info['redis_version'], $date->format(DATE_RFC2822))); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | \ No newline at end of file |
@@ -136,9 +136,9 @@ |
||
136 | 136 | $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]); |
137 | 137 | |
138 | 138 | return (new driverStatistic()) |
139 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
140 | - ->setInfo(sprintf("The APCU cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822), $stats[ 'num_entries' ])) |
|
141 | - ->setRawData($stats) |
|
142 | - ->setSize($stats[ 'mem_size' ]); |
|
139 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
140 | + ->setInfo(sprintf("The APCU cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822), $stats[ 'num_entries' ])) |
|
141 | + ->setRawData($stats) |
|
142 | + ->setSize($stats[ 'mem_size' ]); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | \ No newline at end of file |
@@ -133,12 +133,12 @@ |
||
133 | 133 | public function getStats() |
134 | 134 | { |
135 | 135 | $stats = (array) apc_cache_info('user'); |
136 | - $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]); |
|
136 | + $date = (new \DateTime())->setTimestamp($stats['start_time']); |
|
137 | 137 | |
138 | 138 | return (new driverStatistic()) |
139 | 139 | ->setData(implode(', ', array_keys($this->itemInstances))) |
140 | - ->setInfo(sprintf("The APCU cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822), $stats[ 'num_entries' ])) |
|
140 | + ->setInfo(sprintf("The APCU cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822), $stats['num_entries'])) |
|
141 | 141 | ->setRawData($stats) |
142 | - ->setSize($stats[ 'mem_size' ]); |
|
142 | + ->setSize($stats['mem_size']); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | \ No newline at end of file |
@@ -15,7 +15,6 @@ |
||
15 | 15 | namespace phpFastCache\Drivers\Wincache; |
16 | 16 | |
17 | 17 | use phpFastCache\Core\DriverAbstract; |
18 | -use phpFastCache\Core\StandardPsr6StructureTrait; |
|
19 | 18 | use phpFastCache\Entities\driverStatistic; |
20 | 19 | use phpFastCache\Exceptions\phpFastCacheDriverCheckException; |
21 | 20 | use phpFastCache\Exceptions\phpFastCacheDriverException; |
@@ -132,9 +132,9 @@ |
||
132 | 132 | $date = (new \DateTime())->setTimestamp(time() - $info[ 'total_cache_uptime' ]); |
133 | 133 | |
134 | 134 | return (new driverStatistic()) |
135 | - ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822))) |
|
136 | - ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ]) |
|
137 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
138 | - ->setRawData($memInfo); |
|
135 | + ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822))) |
|
136 | + ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ]) |
|
137 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
138 | + ->setRawData($memInfo); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | \ No newline at end of file |
@@ -129,11 +129,11 @@ |
||
129 | 129 | { |
130 | 130 | $memInfo = wincache_ucache_meminfo(); |
131 | 131 | $info = wincache_ucache_info(); |
132 | - $date = (new \DateTime())->setTimestamp(time() - $info[ 'total_cache_uptime' ]); |
|
132 | + $date = (new \DateTime())->setTimestamp(time() - $info['total_cache_uptime']); |
|
133 | 133 | |
134 | 134 | return (new driverStatistic()) |
135 | 135 | ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822))) |
136 | - ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ]) |
|
136 | + ->setSize($memInfo['memory_free'] - $memInfo['memory_total']) |
|
137 | 137 | ->setData(implode(', ', array_keys($this->itemInstances))) |
138 | 138 | ->setRawData($memInfo); |
139 | 139 | } |
@@ -15,7 +15,6 @@ |
||
15 | 15 | namespace phpFastCache\Drivers\Wincache; |
16 | 16 | |
17 | 17 | use phpFastCache\Core\DriverAbstract; |
18 | -use phpFastCache\Core\StandardPsr6StructureTrait; |
|
19 | 18 | use phpFastCache\Entities\driverStatistic; |
20 | 19 | use phpFastCache\Exceptions\phpFastCacheDriverCheckException; |
21 | 20 | use phpFastCache\Exceptions\phpFastCacheDriverException; |
@@ -136,10 +136,10 @@ |
||
136 | 136 | $info = xcache_info(XC_TYPE_VAR, 0); |
137 | 137 | |
138 | 138 | return (new driverStatistic()) |
139 | - ->setSize(abs($info[ 'size' ] - $info[ 'avail' ])) |
|
140 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
141 | - ->setInfo(sprintf("Xcache v%s with following modules loaded:\n %s", XCACHE_VERSION, str_replace(' ', ', ', XCACHE_MODULES))) |
|
142 | - ->setRawData($info); |
|
139 | + ->setSize(abs($info[ 'size' ] - $info[ 'avail' ])) |
|
140 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
141 | + ->setInfo(sprintf("Xcache v%s with following modules loaded:\n %s", XCACHE_VERSION, str_replace(' ', ', ', XCACHE_MODULES))) |
|
142 | + ->setRawData($info); |
|
143 | 143 | } else { |
144 | 144 | throw new \RuntimeException("PhpFastCache is not able to read Xcache configuration. Please put this to your php.ini:\n |
145 | 145 | [xcache.admin] |
@@ -136,7 +136,7 @@ |
||
136 | 136 | $info = xcache_info(XC_TYPE_VAR, 0); |
137 | 137 | |
138 | 138 | return (new driverStatistic()) |
139 | - ->setSize(abs($info[ 'size' ] - $info[ 'avail' ])) |
|
139 | + ->setSize(abs($info['size'] - $info['avail'])) |
|
140 | 140 | ->setData(implode(', ', array_keys($this->itemInstances))) |
141 | 141 | ->setInfo(sprintf("Xcache v%s with following modules loaded:\n %s", XCACHE_VERSION, str_replace(' ', ', ', XCACHE_MODULES))) |
142 | 142 | ->setRawData($info); |
@@ -136,10 +136,10 @@ |
||
136 | 136 | $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]); |
137 | 137 | |
138 | 138 | return (new driverStatistic()) |
139 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
140 | - ->setInfo(sprintf("The APC cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822), |
|
139 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
140 | + ->setInfo(sprintf("The APC cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822), |
|
141 | 141 | $stats[ 'num_entries' ])) |
142 | - ->setRawData($stats) |
|
143 | - ->setSize($stats[ 'mem_size' ]); |
|
142 | + ->setRawData($stats) |
|
143 | + ->setSize($stats[ 'mem_size' ]); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | \ No newline at end of file |
@@ -133,13 +133,13 @@ |
||
133 | 133 | public function getStats() |
134 | 134 | { |
135 | 135 | $stats = (array) apc_cache_info('user'); |
136 | - $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]); |
|
136 | + $date = (new \DateTime())->setTimestamp($stats['start_time']); |
|
137 | 137 | |
138 | 138 | return (new driverStatistic()) |
139 | 139 | ->setData(implode(', ', array_keys($this->itemInstances))) |
140 | 140 | ->setInfo(sprintf("The APC cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822), |
141 | - $stats[ 'num_entries' ])) |
|
141 | + $stats['num_entries'])) |
|
142 | 142 | ->setRawData($stats) |
143 | - ->setSize($stats[ 'mem_size' ]); |
|
143 | + ->setSize($stats['mem_size']); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | \ No newline at end of file |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
132 | 132 | if (count($servers) < 1) { |
133 | 133 | $servers = [ |
134 | - ['127.0.0.1', 11211], |
|
134 | + ['127.0.0.1', 11211], |
|
135 | 135 | ]; |
136 | 136 | } |
137 | 137 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
162 | 162 | |
163 | 163 | return (new driverStatistic()) |
164 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
165 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
166 | - ->setRawData($stats) |
|
167 | - ->setSize($stats[ 'bytes' ]); |
|
164 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
165 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
166 | + ->setRawData($stats) |
|
167 | + ->setSize($stats[ 'bytes' ]); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | \ No newline at end of file |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $this->instance = new MemcacheSoftware(); |
53 | 53 | $this->driverConnect(); |
54 | 54 | |
55 | - if (array_key_exists('compress_data', $config) && $config[ 'compress_data' ] === true) { |
|
55 | + if (array_key_exists('compress_data', $config) && $config['compress_data'] === true) { |
|
56 | 56 | $this->memcacheFlags = MEMCACHE_COMPRESSED; |
57 | 57 | } |
58 | 58 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function driverConnect() |
130 | 130 | { |
131 | - $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
|
131 | + $servers = (!empty($this->config['memcache']) && is_array($this->config['memcache']) ? $this->config['memcache'] : []); |
|
132 | 132 | if (count($servers) < 1) { |
133 | 133 | $servers = [ |
134 | 134 | ['127.0.0.1', 11211], |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | |
138 | 138 | foreach ($servers as $server) { |
139 | 139 | try { |
140 | - if (!$this->instance->addserver($server[ 0 ], $server[ 1 ])) { |
|
140 | + if (!$this->instance->addserver($server[0], $server[1])) { |
|
141 | 141 | $this->fallback = true; |
142 | 142 | } |
143 | - if(!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password'])){ |
|
144 | - $this->instance->setSaslAuthData($server[ 'sasl_user' ], $server[ 'sasl_password']); |
|
143 | + if (!empty($server['sasl_user']) && !empty($server['sasl_password'])) { |
|
144 | + $this->instance->setSaslAuthData($server['sasl_user'], $server['sasl_password']); |
|
145 | 145 | } |
146 | 146 | } catch (\Exception $e) { |
147 | 147 | $this->fallback = true; |
@@ -161,16 +161,16 @@ discard block |
||
161 | 161 | public function getStats() |
162 | 162 | { |
163 | 163 | $stats = (array) $this->instance->getstats(); |
164 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
165 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion'); |
|
166 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
164 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
165 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion'); |
|
166 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
167 | 167 | |
168 | - $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
168 | + $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
|
169 | 169 | |
170 | 170 | return (new driverStatistic()) |
171 | 171 | ->setData(implode(', ', array_keys($this->itemInstances))) |
172 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
172 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
173 | 173 | ->setRawData($stats) |
174 | - ->setSize($stats[ 'bytes' ]); |
|
174 | + ->setSize($stats['bytes']); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | \ No newline at end of file |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | { |
140 | 140 | try { |
141 | 141 | $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [ |
142 | - 'host' => "127.0.0.1", |
|
143 | - 'port' => 8888, |
|
144 | - 'password' => '', |
|
145 | - 'timeout' => 2000, |
|
142 | + 'host' => "127.0.0.1", |
|
143 | + 'port' => 8888, |
|
144 | + 'password' => '', |
|
145 | + 'timeout' => 2000, |
|
146 | 146 | ]; |
147 | 147 | |
148 | 148 | $host = $server[ 'host' ]; |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * using hardcoded offset of pair key-value :-( |
184 | 184 | */ |
185 | 185 | $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[ 2 ], $info[ 6 ])) |
186 | - ->setRawData($info) |
|
187 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
188 | - ->setSize($this->instance->dbsize()); |
|
186 | + ->setRawData($info) |
|
187 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
188 | + ->setSize($this->instance->dbsize()); |
|
189 | 189 | |
190 | 190 | return $stat; |
191 | 191 | } |
@@ -138,17 +138,17 @@ discard block |
||
138 | 138 | protected function driverConnect() |
139 | 139 | { |
140 | 140 | try { |
141 | - $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [ |
|
141 | + $server = isset($this->config['ssdb']) ? $this->config['ssdb'] : [ |
|
142 | 142 | 'host' => "127.0.0.1", |
143 | 143 | 'port' => 8888, |
144 | 144 | 'password' => '', |
145 | 145 | 'timeout' => 2000, |
146 | 146 | ]; |
147 | 147 | |
148 | - $host = $server[ 'host' ]; |
|
149 | - $port = isset($server[ 'port' ]) ? (int) $server[ 'port' ] : 8888; |
|
150 | - $password = isset($server[ 'password' ]) ? $server[ 'password' ] : ''; |
|
151 | - $timeout = !empty($server[ 'timeout' ]) ? (int) $server[ 'timeout' ] : 2000; |
|
148 | + $host = $server['host']; |
|
149 | + $port = isset($server['port']) ? (int) $server['port'] : 8888; |
|
150 | + $password = isset($server['password']) ? $server['password'] : ''; |
|
151 | + $timeout = !empty($server['timeout']) ? (int) $server['timeout'] : 2000; |
|
152 | 152 | $this->instance = new SimpleSSDB($host, $port, $timeout); |
153 | 153 | if (!empty($password)) { |
154 | 154 | $this->instance->auth($password); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * Data returned by Ssdb are very poorly formatted |
183 | 183 | * using hardcoded offset of pair key-value :-( |
184 | 184 | */ |
185 | - $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[ 2 ], $info[ 6 ])) |
|
185 | + $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[2], $info[6])) |
|
186 | 186 | ->setRawData($info) |
187 | 187 | ->setData(implode(', ', array_keys($this->itemInstances))) |
188 | 188 | ->setSize($this->instance->dbsize()); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
132 | 132 | if (count($servers) < 1) { |
133 | 133 | $servers = [ |
134 | - ['127.0.0.1', 11211], |
|
134 | + ['127.0.0.1', 11211], |
|
135 | 135 | ]; |
136 | 136 | } |
137 | 137 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
162 | 162 | |
163 | 163 | return (new driverStatistic()) |
164 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
165 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
166 | - ->setRawData($stats) |
|
167 | - ->setSize($stats[ 'bytes' ]); |
|
164 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
165 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
166 | + ->setRawData($stats) |
|
167 | + ->setSize($stats[ 'bytes' ]); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | \ No newline at end of file |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function driverConnect() |
129 | 129 | { |
130 | - $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
|
130 | + $servers = (!empty($this->config['memcache']) && is_array($this->config['memcache']) ? $this->config['memcache'] : []); |
|
131 | 131 | if (count($servers) < 1) { |
132 | 132 | $servers = [ |
133 | 133 | ['127.0.0.1', 11211], |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | |
137 | 137 | foreach ($servers as $server) { |
138 | 138 | try { |
139 | - if (!$this->instance->addServer($server[ 0 ], $server[ 1 ])) { |
|
139 | + if (!$this->instance->addServer($server[0], $server[1])) { |
|
140 | 140 | $this->fallback = true; |
141 | 141 | } |
142 | - if(!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password'])){ |
|
143 | - $this->instance->setSaslAuthData($server[ 'sasl_user' ], $server[ 'sasl_password']); |
|
142 | + if (!empty($server['sasl_user']) && !empty($server['sasl_password'])) { |
|
143 | + $this->instance->setSaslAuthData($server['sasl_user'], $server['sasl_password']); |
|
144 | 144 | } |
145 | 145 | } catch (\Exception $e) { |
146 | 146 | $this->fallback = true; |
@@ -160,16 +160,16 @@ discard block |
||
160 | 160 | public function getStats() |
161 | 161 | { |
162 | 162 | $stats = (array) $this->instance->getStats(); |
163 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
164 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion'); |
|
165 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
163 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
164 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion'); |
|
165 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
166 | 166 | |
167 | - $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
167 | + $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
|
168 | 168 | |
169 | 169 | return (new driverStatistic()) |
170 | 170 | ->setData(implode(', ', array_keys($this->itemInstances))) |
171 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
171 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
172 | 172 | ->setRawData($stats) |
173 | - ->setSize($stats[ 'bytes' ]); |
|
173 | + ->setSize($stats['bytes']); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | \ No newline at end of file |