@@ -75,16 +75,16 @@ discard block |
||
| 75 | 75 | try{ |
| 76 | 76 | $cacheData = $this->encode($this->driverPreWrap($item)); |
| 77 | 77 | $options = new Cassandra\ExecutionOptions([ |
| 78 | - 'arguments' => [ |
|
| 78 | + 'arguments' => [ |
|
| 79 | 79 | 'cache_uuid' => new Cassandra\Uuid(), |
| 80 | 80 | 'cache_id' => $item->getKey(), |
| 81 | 81 | 'cache_data' => $cacheData, |
| 82 | 82 | 'cache_creation_date' => new Cassandra\Timestamp((new \DateTime())->getTimestamp()), |
| 83 | 83 | 'cache_expiration_date' => new Cassandra\Timestamp($item->getExpirationDate()->getTimestamp()), |
| 84 | 84 | 'cache_length' => strlen($cacheData) |
| 85 | - ], |
|
| 86 | - 'consistency' => Cassandra::CONSISTENCY_ALL, |
|
| 87 | - 'serial_consistency' => Cassandra::CONSISTENCY_SERIAL |
|
| 85 | + ], |
|
| 86 | + 'consistency' => Cassandra::CONSISTENCY_ALL, |
|
| 87 | + 'serial_consistency' => Cassandra::CONSISTENCY_SERIAL |
|
| 88 | 88 | ]); |
| 89 | 89 | |
| 90 | 90 | $query = sprintf('INSERT INTO %s.%s |
@@ -122,13 +122,13 @@ discard block |
||
| 122 | 122 | { |
| 123 | 123 | try { |
| 124 | 124 | $options = new Cassandra\ExecutionOptions([ |
| 125 | - 'arguments' => ['cache_id' => $item->getKey()], |
|
| 126 | - 'page_size' => 1 |
|
| 125 | + 'arguments' => ['cache_id' => $item->getKey()], |
|
| 126 | + 'page_size' => 1 |
|
| 127 | 127 | ]); |
| 128 | 128 | $query = sprintf( |
| 129 | - 'SELECT cache_data FROM %s.%s WHERE cache_id = :cache_id;', |
|
| 130 | - self::CASSANDRA_KEY_SPACE, |
|
| 131 | - self::CASSANDRA_TABLE |
|
| 129 | + 'SELECT cache_data FROM %s.%s WHERE cache_id = :cache_id;', |
|
| 130 | + self::CASSANDRA_KEY_SPACE, |
|
| 131 | + self::CASSANDRA_TABLE |
|
| 132 | 132 | ); |
| 133 | 133 | $results = $this->instance->execute(new Cassandra\SimpleStatement($query), $options); |
| 134 | 134 | |
@@ -155,14 +155,14 @@ discard block |
||
| 155 | 155 | if ($item instanceof Item) { |
| 156 | 156 | try { |
| 157 | 157 | $options = new Cassandra\ExecutionOptions([ |
| 158 | - 'arguments' => [ |
|
| 158 | + 'arguments' => [ |
|
| 159 | 159 | 'cache_id' => $item->getKey(), |
| 160 | - ], |
|
| 160 | + ], |
|
| 161 | 161 | ]); |
| 162 | 162 | $result = $this->instance->execute(new Cassandra\SimpleStatement(sprintf( |
| 163 | - 'DELETE FROM %s.%s WHERE cache_id = :cache_id;', |
|
| 164 | - self::CASSANDRA_KEY_SPACE, |
|
| 165 | - self::CASSANDRA_TABLE |
|
| 163 | + 'DELETE FROM %s.%s WHERE cache_id = :cache_id;', |
|
| 164 | + self::CASSANDRA_KEY_SPACE, |
|
| 165 | + self::CASSANDRA_TABLE |
|
| 166 | 166 | )), $options); |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | { |
| 187 | 187 | try { |
| 188 | 188 | $this->instance->execute(new Cassandra\SimpleStatement(sprintf( |
| 189 | - 'TRUNCATE %s.%s;', |
|
| 190 | - self::CASSANDRA_KEY_SPACE, self::CASSANDRA_TABLE |
|
| 189 | + 'TRUNCATE %s.%s;', |
|
| 190 | + self::CASSANDRA_KEY_SPACE, self::CASSANDRA_TABLE |
|
| 191 | 191 | ))); |
| 192 | 192 | |
| 193 | 193 | return true; |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
| 214 | 214 | |
| 215 | 215 | $clusterBuilder = Cassandra::cluster() |
| 216 | - ->withContactPoints($host) |
|
| 217 | - ->withPort($port); |
|
| 216 | + ->withContactPoints($host) |
|
| 217 | + ->withPort($port); |
|
| 218 | 218 | |
| 219 | 219 | if(!empty($this->config['ssl']['enabled'])){ |
| 220 | 220 | if(!empty($this->config['ssl']['verify'])){ |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | |
| 244 | 244 | $this->instance->execute(new Cassandra\SimpleStatement(sprintf( |
| 245 | - "CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", |
|
| 246 | - self::CASSANDRA_KEY_SPACE |
|
| 245 | + "CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", |
|
| 246 | + self::CASSANDRA_KEY_SPACE |
|
| 247 | 247 | ))); |
| 248 | 248 | $this->instance->execute(new Cassandra\SimpleStatement(sprintf('USE %s;', self::CASSANDRA_KEY_SPACE))); |
| 249 | 249 | $this->instance->execute(new Cassandra\SimpleStatement(sprintf(' |
@@ -290,15 +290,15 @@ discard block |
||
| 290 | 290 | public function getStats() |
| 291 | 291 | { |
| 292 | 292 | $result = $this->instance->execute(new Cassandra\SimpleStatement(sprintf( |
| 293 | - 'SELECT SUM(cache_length) as cache_size FROM %s.%s', |
|
| 294 | - self::CASSANDRA_KEY_SPACE, |
|
| 295 | - self::CASSANDRA_TABLE |
|
| 293 | + 'SELECT SUM(cache_length) as cache_size FROM %s.%s', |
|
| 294 | + self::CASSANDRA_KEY_SPACE, |
|
| 295 | + self::CASSANDRA_TABLE |
|
| 296 | 296 | ))); |
| 297 | 297 | |
| 298 | 298 | return (new DriverStatistic()) |
| 299 | - ->setSize($result->first()[ 'cache_size' ]) |
|
| 300 | - ->setRawData([]) |
|
| 301 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 302 | - ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.'); |
|
| 299 | + ->setSize($result->first()[ 'cache_size' ]) |
|
| 300 | + ->setRawData([]) |
|
| 301 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 302 | + ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.'); |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | \ No newline at end of file |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * Check for Cross-Driver type confusion |
| 73 | 73 | */ |
| 74 | 74 | if ($item instanceof Item) { |
| 75 | - try{ |
|
| 75 | + try { |
|
| 76 | 76 | $cacheData = $this->encode($this->driverPreWrap($item)); |
| 77 | 77 | $options = new Cassandra\ExecutionOptions([ |
| 78 | 78 | 'arguments' => [ |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * been really upserted |
| 107 | 107 | */ |
| 108 | 108 | return $result instanceof Cassandra\Rows; |
| 109 | - }catch(\Cassandra\Exception\InvalidArgumentException $e){ |
|
| 109 | + } catch (\Cassandra\Exception\InvalidArgumentException $e) { |
|
| 110 | 110 | throw new phpFastCacheInvalidArgumentException($e, 0, $e); |
| 111 | 111 | } |
| 112 | 112 | } else { |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | ); |
| 133 | 133 | $results = $this->instance->execute(new Cassandra\SimpleStatement($query), $options); |
| 134 | 134 | |
| 135 | - if($results instanceof Cassandra\Rows && $results->count() === 1){ |
|
| 135 | + if ($results instanceof Cassandra\Rows && $results->count() === 1) { |
|
| 136 | 136 | return $this->decode($results->first()['cache_data']); |
| 137 | - }else{ |
|
| 137 | + } else { |
|
| 138 | 138 | return null; |
| 139 | 139 | } |
| 140 | 140 | } catch (Cassandra\Exception $e) { |
@@ -206,20 +206,20 @@ discard block |
||
| 206 | 206 | if ($this->instance instanceof CassandraSession) { |
| 207 | 207 | throw new phpFastCacheLogicException('Already connected to Couchbase server'); |
| 208 | 208 | } else { |
| 209 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
| 210 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : 9042; |
|
| 211 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 2; |
|
| 212 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
| 213 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
| 209 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
| 210 | + $port = isset($this->config['port']) ? $this->config['port'] : 9042; |
|
| 211 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 2; |
|
| 212 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
| 213 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
| 214 | 214 | |
| 215 | 215 | $clusterBuilder = Cassandra::cluster() |
| 216 | 216 | ->withContactPoints($host) |
| 217 | 217 | ->withPort($port); |
| 218 | 218 | |
| 219 | - if(!empty($this->config['ssl']['enabled'])){ |
|
| 220 | - if(!empty($this->config['ssl']['verify'])){ |
|
| 219 | + if (!empty($this->config['ssl']['enabled'])) { |
|
| 220 | + if (!empty($this->config['ssl']['verify'])) { |
|
| 221 | 221 | $sslBuilder = Cassandra::ssl()->withVerifyFlags(Cassandra::VERIFY_PEER_CERT); |
| 222 | - }else{ |
|
| 222 | + } else { |
|
| 223 | 223 | $sslBuilder = Cassandra::ssl()->withVerifyFlags(Cassandra::VERIFY_NONE); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | $clusterBuilder->withConnectTimeout($timeout); |
| 230 | 230 | |
| 231 | - if($username){ |
|
| 231 | + if ($username) { |
|
| 232 | 232 | $clusterBuilder->withCredentials($username, $password); |
| 233 | 233 | } |
| 234 | 234 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | ))); |
| 297 | 297 | |
| 298 | 298 | return (new DriverStatistic()) |
| 299 | - ->setSize($result->first()[ 'cache_size' ]) |
|
| 299 | + ->setSize($result->first()['cache_size']) |
|
| 300 | 300 | ->setRawData([]) |
| 301 | 301 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 302 | 302 | ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.'); |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | protected function driverRead(CacheItemInterface $item) |
| 81 | 81 | { |
| 82 | 82 | return [ |
| 83 | - self::DRIVER_DATA_WRAPPER_INDEX => true, |
|
| 84 | - self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
| 85 | - self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(), |
|
| 83 | + self::DRIVER_DATA_WRAPPER_INDEX => true, |
|
| 84 | + self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
| 85 | + self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(), |
|
| 86 | 86 | ]; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | $stat = new DriverStatistic(); |
| 134 | 134 | $stat->setInfo('[Devtrue] A void info string') |
| 135 | - ->setSize(0) |
|
| 136 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 137 | - ->setRawData(true); |
|
| 135 | + ->setSize(0) |
|
| 136 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 137 | + ->setRawData(true); |
|
| 138 | 138 | |
| 139 | 139 | return $stat; |
| 140 | 140 | } |
@@ -133,9 +133,9 @@ |
||
| 133 | 133 | $date = (new \DateTime())->setTimestamp(time() - $info[ 'total_cache_uptime' ]); |
| 134 | 134 | |
| 135 | 135 | return (new DriverStatistic()) |
| 136 | - ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822))) |
|
| 137 | - ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ]) |
|
| 138 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 139 | - ->setRawData($memInfo); |
|
| 136 | + ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822))) |
|
| 137 | + ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ]) |
|
| 138 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 139 | + ->setRawData($memInfo); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | \ No newline at end of file |
@@ -130,11 +130,11 @@ |
||
| 130 | 130 | { |
| 131 | 131 | $memInfo = wincache_ucache_meminfo(); |
| 132 | 132 | $info = wincache_ucache_info(); |
| 133 | - $date = (new \DateTime())->setTimestamp(time() - $info[ 'total_cache_uptime' ]); |
|
| 133 | + $date = (new \DateTime())->setTimestamp(time() - $info['total_cache_uptime']); |
|
| 134 | 134 | |
| 135 | 135 | return (new DriverStatistic()) |
| 136 | 136 | ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822))) |
| 137 | - ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ]) |
|
| 137 | + ->setSize($memInfo['memory_free'] - $memInfo['memory_total']) |
|
| 138 | 138 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 139 | 139 | ->setRawData($memInfo); |
| 140 | 140 | } |
@@ -147,8 +147,8 @@ |
||
| 147 | 147 | $stats = (array) zend_shm_cache_info(); |
| 148 | 148 | return (new DriverStatistic()) |
| 149 | 149 | ->setData(implode(', ', array_keys($this->namespaces))) |
| 150 | - ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.",$stats[ 'items_total' ])) |
|
| 150 | + ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total'])) |
|
| 151 | 151 | ->setRawData($stats) |
| 152 | - ->setSize($stats[ 'memory_total' ]); |
|
| 152 | + ->setSize($stats['memory_total']); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | \ No newline at end of file |
@@ -88,15 +88,15 @@ discard block |
||
| 88 | 88 | if ($item instanceof Item) { |
| 89 | 89 | try { |
| 90 | 90 | $result = (array) $this->getCollection()->updateOne( |
| 91 | - ['_id' => $item->getEncodedKey()], |
|
| 92 | - [ |
|
| 91 | + ['_id' => $item->getEncodedKey()], |
|
| 92 | + [ |
|
| 93 | 93 | '$set' => [ |
| 94 | - self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC), |
|
| 95 | - self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC), |
|
| 96 | - self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time()*1000)), |
|
| 94 | + self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC), |
|
| 95 | + self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC), |
|
| 96 | + self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((time() + $item->getTtl()) * 1000) : new UTCDateTime(time()*1000)), |
|
| 97 | 97 | ], |
| 98 | - ], |
|
| 99 | - ['upsert' => true, 'multiple' => false] |
|
| 98 | + ], |
|
| 99 | + ['upsert' => true, 'multiple' => false] |
|
| 100 | 100 | ); |
| 101 | 101 | } catch (MongoDBException $e) { |
| 102 | 102 | throw new phpFastCacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e); |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | if ($document) { |
| 120 | 120 | return [ |
| 121 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
| 122 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
| 123 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
| 121 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
| 122 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
| 123 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
| 124 | 124 | ]; |
| 125 | 125 | } else { |
| 126 | 126 | return null; |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | * @todo make an url builder |
| 192 | 192 | */ |
| 193 | 193 | $this->instance = $this->instance ?: (new MongodbManager('mongodb://' . |
| 194 | - ($username ?: '') . |
|
| 195 | - ($password ? ":{$password}" : '') . |
|
| 196 | - ($username ? '@' : '') . "{$host}" . |
|
| 197 | - ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000])); |
|
| 194 | + ($username ?: '') . |
|
| 195 | + ($password ? ":{$password}" : '') . |
|
| 196 | + ($username ? '@' : '') . "{$host}" . |
|
| 197 | + ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000])); |
|
| 198 | 198 | $this->collection = $this->collection ?: new Collection($this->instance,$databaseName, $collectionName); |
| 199 | 199 | |
| 200 | 200 | return true; |
@@ -222,15 +222,15 @@ discard block |
||
| 222 | 222 | public function getStats() |
| 223 | 223 | { |
| 224 | 224 | $serverStats = $this->instance->executeCommand('phpFastCache', new Command([ |
| 225 | - 'serverStatus' => 1, |
|
| 226 | - 'recordStats' => 0, |
|
| 227 | - 'repl' => 0, |
|
| 228 | - 'metrics' => 0, |
|
| 225 | + 'serverStatus' => 1, |
|
| 226 | + 'recordStats' => 0, |
|
| 227 | + 'repl' => 0, |
|
| 228 | + 'metrics' => 0, |
|
| 229 | 229 | ]))->toArray()[0]; |
| 230 | 230 | |
| 231 | 231 | $collectionStats = $this->instance->executeCommand('phpFastCache', new Command([ |
| 232 | - 'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'), |
|
| 233 | - 'verbose' => true, |
|
| 232 | + 'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'), |
|
| 233 | + 'verbose' => true, |
|
| 234 | 234 | ]))->toArray()[0]; |
| 235 | 235 | |
| 236 | 236 | $array_filter_recursive = function( $array, callable $callback = null ) use(&$array_filter_recursive) { |
@@ -260,13 +260,13 @@ discard block |
||
| 260 | 260 | $collectionStats = $array_filter_recursive($collectionStats, $callback); |
| 261 | 261 | |
| 262 | 262 | $stats = (new DriverStatistic()) |
| 263 | - ->setInfo('MongoDB version ' . $serverStats->version . ', Uptime (in days): ' . round($serverStats->uptime / 86400, 1) . "\n For more information see RawData.") |
|
| 264 | - ->setSize($collectionStats->size) |
|
| 265 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 266 | - ->setRawData([ |
|
| 263 | + ->setInfo('MongoDB version ' . $serverStats->version . ', Uptime (in days): ' . round($serverStats->uptime / 86400, 1) . "\n For more information see RawData.") |
|
| 264 | + ->setSize($collectionStats->size) |
|
| 265 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 266 | + ->setRawData([ |
|
| 267 | 267 | 'serverStatus' => $serverStats, |
| 268 | 268 | 'collStats' => $collectionStats, |
| 269 | - ]); |
|
| 269 | + ]); |
|
| 270 | 270 | |
| 271 | 271 | return $stats; |
| 272 | 272 | } |
@@ -137,10 +137,10 @@ |
||
| 137 | 137 | $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]); |
| 138 | 138 | |
| 139 | 139 | return (new DriverStatistic()) |
| 140 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 141 | - ->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), |
|
| 140 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 141 | + ->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), |
|
| 142 | 142 | $stats[ 'num_entries' ])) |
| 143 | - ->setRawData($stats) |
|
| 144 | - ->setSize($stats[ 'mem_size' ]); |
|
| 143 | + ->setRawData($stats) |
|
| 144 | + ->setSize($stats[ 'mem_size' ]); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | \ No newline at end of file |
@@ -134,13 +134,13 @@ |
||
| 134 | 134 | public function getStats() |
| 135 | 135 | { |
| 136 | 136 | $stats = (array) apc_cache_info('user'); |
| 137 | - $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]); |
|
| 137 | + $date = (new \DateTime())->setTimestamp($stats['start_time']); |
|
| 138 | 138 | |
| 139 | 139 | return (new DriverStatistic()) |
| 140 | 140 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 141 | 141 | ->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), |
| 142 | - $stats[ 'num_entries' ])) |
|
| 142 | + $stats['num_entries'])) |
|
| 143 | 143 | ->setRawData($stats) |
| 144 | - ->setSize($stats[ 'mem_size' ]); |
|
| 144 | + ->setSize($stats['mem_size']); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | \ No newline at end of file |
@@ -137,10 +137,10 @@ |
||
| 137 | 137 | $info = xcache_info(XC_TYPE_VAR, 0); |
| 138 | 138 | |
| 139 | 139 | return (new DriverStatistic()) |
| 140 | - ->setSize(abs($info[ 'size' ] - $info[ 'avail' ])) |
|
| 141 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 142 | - ->setInfo(sprintf("Xcache v%s with following modules loaded:\n %s", XCACHE_VERSION, str_replace(' ', ', ', XCACHE_MODULES))) |
|
| 143 | - ->setRawData($info); |
|
| 140 | + ->setSize(abs($info[ 'size' ] - $info[ 'avail' ])) |
|
| 141 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 142 | + ->setInfo(sprintf("Xcache v%s with following modules loaded:\n %s", XCACHE_VERSION, str_replace(' ', ', ', XCACHE_MODULES))) |
|
| 143 | + ->setRawData($info); |
|
| 144 | 144 | } else { |
| 145 | 145 | throw new \RuntimeException("PhpFastCache is not able to read Xcache configuration. Please put this to your php.ini:\n |
| 146 | 146 | [xcache.admin] |
@@ -137,7 +137,7 @@ |
||
| 137 | 137 | $info = xcache_info(XC_TYPE_VAR, 0); |
| 138 | 138 | |
| 139 | 139 | return (new DriverStatistic()) |
| 140 | - ->setSize(abs($info[ 'size' ] - $info[ 'avail' ])) |
|
| 140 | + ->setSize(abs($info['size'] - $info['avail'])) |
|
| 141 | 141 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 142 | 142 | ->setInfo(sprintf("Xcache v%s with following modules loaded:\n %s", XCACHE_VERSION, str_replace(' ', ', ', XCACHE_MODULES))) |
| 143 | 143 | ->setRawData($info); |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | $config = isset($this->config[ 'predis' ]) ? $this->config[ 'predis' ] : []; |
| 127 | 127 | |
| 128 | 128 | $this->instance = new PredisClient(array_merge([ |
| 129 | - 'host' => '127.0.0.1', |
|
| 130 | - 'port' => 6379, |
|
| 131 | - 'password' => null, |
|
| 132 | - 'database' => null, |
|
| 129 | + 'host' => '127.0.0.1', |
|
| 130 | + 'port' => 6379, |
|
| 131 | + 'password' => null, |
|
| 132 | + 'database' => null, |
|
| 133 | 133 | ], $config)); |
| 134 | 134 | |
| 135 | 135 | return true; |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | $date = (isset($info['Server'][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info['Server'][ 'uptime_in_seconds' ]) : 'unknown date'); |
| 153 | 153 | |
| 154 | 154 | return (new DriverStatistic()) |
| 155 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 156 | - ->setRawData($info) |
|
| 157 | - ->setSize($size) |
|
| 158 | - ->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.", $version, $date->format(DATE_RFC2822))); |
|
| 155 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 156 | + ->setRawData($info) |
|
| 157 | + ->setSize($size) |
|
| 158 | + ->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.", $version, $date->format(DATE_RFC2822))); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | \ No newline at end of file |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | protected function driverConnect() |
| 125 | 125 | { |
| 126 | - $config = isset($this->config[ 'predis' ]) ? $this->config[ 'predis' ] : []; |
|
| 126 | + $config = isset($this->config['predis']) ? $this->config['predis'] : []; |
|
| 127 | 127 | |
| 128 | 128 | $this->instance = new PredisClient(array_merge([ |
| 129 | 129 | 'host' => '127.0.0.1', |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $info = $this->instance->info(); |
| 150 | 150 | $size = (isset($info['Memory']['used_memory']) ? $info['Memory']['used_memory'] : 0); |
| 151 | 151 | $version = (isset($info['Server']['redis_version']) ? $info['Server']['redis_version'] : 0); |
| 152 | - $date = (isset($info['Server'][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info['Server'][ 'uptime_in_seconds' ]) : 'unknown date'); |
|
| 152 | + $date = (isset($info['Server']['uptime_in_seconds']) ? (new \DateTime())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
| 153 | 153 | |
| 154 | 154 | return (new DriverStatistic()) |
| 155 | 155 | ->setData(implode(', ', array_keys($this->itemInstances))) |
@@ -132,12 +132,12 @@ discard block |
||
| 132 | 132 | $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
| 133 | 133 | if (count($servers) < 1) { |
| 134 | 134 | $servers = [ |
| 135 | - [ |
|
| 135 | + [ |
|
| 136 | 136 | 'host' =>'127.0.0.1', |
| 137 | 137 | 'port' => 11211, |
| 138 | 138 | 'sasl_user' => false, |
| 139 | 139 | 'sasl_password' => false |
| 140 | - ], |
|
| 140 | + ], |
|
| 141 | 141 | ]; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
| 175 | 175 | |
| 176 | 176 | return (new DriverStatistic()) |
| 177 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 178 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
| 179 | - ->setRawData($stats) |
|
| 180 | - ->setSize($stats[ 'bytes' ]); |
|
| 177 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 178 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
| 179 | + ->setRawData($stats) |
|
| 180 | + ->setSize($stats[ 'bytes' ]); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | \ 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 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | protected function driverConnect() |
| 131 | 131 | { |
| 132 | - $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
|
| 132 | + $servers = (!empty($this->config['servers']) && is_array($this->config['servers']) ? $this->config['servers'] : []); |
|
| 133 | 133 | if (count($servers) < 1) { |
| 134 | 134 | $servers = [ |
| 135 | 135 | [ |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | if (!$this->instance->addServer($server['host'], $server['port'])) { |
| 147 | 147 | $this->fallback = true; |
| 148 | 148 | } |
| 149 | - if(!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password'])){ |
|
| 150 | - $this->instance->setSaslAuthData($server[ 'sasl_user' ], $server[ 'sasl_password']); |
|
| 149 | + if (!empty($server['sasl_user']) && !empty($server['sasl_password'])) { |
|
| 150 | + $this->instance->setSaslAuthData($server['sasl_user'], $server['sasl_password']); |
|
| 151 | 151 | } |
| 152 | 152 | } catch (\Exception $e) { |
| 153 | 153 | $this->fallback = true; |
@@ -167,16 +167,16 @@ discard block |
||
| 167 | 167 | public function getStats() |
| 168 | 168 | { |
| 169 | 169 | $stats = (array) $this->instance->getstats(); |
| 170 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
| 171 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion'); |
|
| 172 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
| 170 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
| 171 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion'); |
|
| 172 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
| 173 | 173 | |
| 174 | - $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
| 174 | + $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
|
| 175 | 175 | |
| 176 | 176 | return (new DriverStatistic()) |
| 177 | 177 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 178 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
| 178 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
| 179 | 179 | ->setRawData($stats) |
| 180 | - ->setSize($stats[ 'bytes' ]); |
|
| 180 | + ->setSize($stats['bytes']); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | \ No newline at end of file |