@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | - * @return array |
|
| 173 | + * @return string[] |
|
| 174 | 174 | */ |
| 175 | 175 | public static function getStaticSystemDrivers() |
| 176 | 176 | { |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | - * @return array |
|
| 197 | + * @return string[] |
|
| 198 | 198 | */ |
| 199 | 199 | public static function getStaticAllDrivers() |
| 200 | 200 | { |
@@ -17,7 +17,6 @@ |
||
| 17 | 17 | use phpFastCache\Cache\ExtendedCacheItemPoolInterface; |
| 18 | 18 | use phpFastCache\Core\DriverAbstract; |
| 19 | 19 | use phpFastCache\Exceptions\phpFastCacheDriverCheckException; |
| 20 | -use CouchbaseCluster; |
|
| 21 | 20 | |
| 22 | 21 | /** |
| 23 | 22 | * Class CacheManager |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | * @var array |
| 53 | 53 | */ |
| 54 | 54 | public static $config = [ |
| 55 | - 'default_chmod' => 0777, // 0777 recommended |
|
| 56 | - 'fallback' => 'files', //Fall back when old driver is not support |
|
| 57 | - 'securityKey' => 'auto', |
|
| 58 | - 'htaccess' => true, |
|
| 59 | - 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
| 60 | - "limited_memory_each_object" => 4096, // maximum size (bytes) of object store in memory |
|
| 61 | - "compress_data" => false, // compress stored data, if the backend supports it |
|
| 55 | + 'default_chmod' => 0777, // 0777 recommended |
|
| 56 | + 'fallback' => 'files', //Fall back when old driver is not support |
|
| 57 | + 'securityKey' => 'auto', |
|
| 58 | + 'htaccess' => true, |
|
| 59 | + 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
| 60 | + "limited_memory_each_object" => 4096, // maximum size (bytes) of object store in memory |
|
| 61 | + "compress_data" => false, // compress stored data, if the backend supports it |
|
| 62 | 62 | ]; |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | $class = self::getNamespacePath() . $driver . '\Driver'; |
| 87 | 87 | self::$instances[ $instance ] = new $class($config); |
| 88 | 88 | } else { |
| 89 | - // trigger_error('[' . $driver . '] Calling CacheManager::getInstance for already instanced drivers is a bad practice and have a significant impact on performances. |
|
| 90 | - // See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
|
| 89 | + // trigger_error('[' . $driver . '] Calling CacheManager::getInstance for already instanced drivers is a bad practice and have a significant impact on performances. |
|
| 90 | + // See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | return self::$instances[ $instance ]; |
@@ -175,21 +175,21 @@ discard block |
||
| 175 | 175 | public static function getStaticSystemDrivers() |
| 176 | 176 | { |
| 177 | 177 | return [ |
| 178 | - 'Sqlite', |
|
| 179 | - 'Files', |
|
| 180 | - 'Apc', |
|
| 181 | - 'Apcu', |
|
| 182 | - 'Memcache', |
|
| 183 | - 'Memcached', |
|
| 184 | - 'Couchbase', |
|
| 185 | - 'Mongodb', |
|
| 186 | - 'Predis', |
|
| 187 | - 'Redis', |
|
| 188 | - 'Ssdb', |
|
| 189 | - 'Leveldb', |
|
| 190 | - 'Wincache', |
|
| 191 | - 'Xcache', |
|
| 192 | - 'Devnull', |
|
| 178 | + 'Sqlite', |
|
| 179 | + 'Files', |
|
| 180 | + 'Apc', |
|
| 181 | + 'Apcu', |
|
| 182 | + 'Memcache', |
|
| 183 | + 'Memcached', |
|
| 184 | + 'Couchbase', |
|
| 185 | + 'Mongodb', |
|
| 186 | + 'Predis', |
|
| 187 | + 'Redis', |
|
| 188 | + 'Ssdb', |
|
| 189 | + 'Leveldb', |
|
| 190 | + 'Wincache', |
|
| 191 | + 'Xcache', |
|
| 192 | + 'Devnull', |
|
| 193 | 193 | ]; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | 'fallback' => 'files', //Fall back when old driver is not support |
| 57 | 57 | 'securityKey' => 'auto', |
| 58 | 58 | 'htaccess' => true, |
| 59 | - 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
| 59 | + 'path' => '', // if not set will be the value of sys_get_temp_dir() |
|
| 60 | 60 | "limited_memory_each_object" => 4096, // maximum size (bytes) of object store in memory |
| 61 | 61 | "compress_data" => false, // compress stored data, if the backend supports it |
| 62 | 62 | ]; |
@@ -82,15 +82,15 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $instance = crc32($driver . serialize($config)); |
| 85 | - if (!isset(self::$instances[ $instance ])) { |
|
| 85 | + if (!isset(self::$instances[$instance])) { |
|
| 86 | 86 | $class = self::getNamespacePath() . $driver . '\Driver'; |
| 87 | - self::$instances[ $instance ] = new $class($config); |
|
| 87 | + self::$instances[$instance] = new $class($config); |
|
| 88 | 88 | } else { |
| 89 | 89 | // trigger_error('[' . $driver . '] Calling CacheManager::getInstance for already instanced drivers is a bad practice and have a significant impact on performances. |
| 90 | 90 | // See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - return self::$instances[ $instance ]; |
|
| 93 | + return self::$instances[$instance]; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public static function __callStatic($name, $arguments) |
| 125 | 125 | { |
| 126 | - $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[ 0 ] : []); |
|
| 126 | + $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[0] : []); |
|
| 127 | 127 | |
| 128 | 128 | return self::getInstance($name, $options); |
| 129 | 129 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | if (is_array($name)) { |
| 166 | 166 | self::$config = array_merge(self::$config, $name); |
| 167 | 167 | } else { |
| 168 | - self::$config[ $name ] = $value; |
|
| 168 | + self::$config[$name] = $value; |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * @param \Psr\Cache\CacheItemInterface $item |
| 60 | - * @return mixed |
|
| 60 | + * @return boolean |
|
| 61 | 61 | * @throws \InvalidArgumentException |
| 62 | 62 | */ |
| 63 | 63 | public function driverWrite(CacheItemInterface $item) |
@@ -154,9 +154,9 @@ |
||
| 154 | 154 | $stats = (array) apc_cache_info('user'); |
| 155 | 155 | $date = (new \DateTime())->setTimestamp($stats['start_time']); |
| 156 | 156 | return (new driverStatistic()) |
| 157 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 158 | - ->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), $stats['num_entries'])) |
|
| 159 | - ->setRawData($stats) |
|
| 160 | - ->setSize($stats['mem_size']); |
|
| 157 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 158 | + ->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), $stats['num_entries'])) |
|
| 159 | + ->setRawData($stats) |
|
| 160 | + ->setSize($stats['mem_size']); |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | \ No newline at end of file |
@@ -175,9 +175,9 @@ |
||
| 175 | 175 | $info = $this->instance->info(); |
| 176 | 176 | $date = (new \DateTime())->setTimestamp(time() - $info['uptime_in_seconds']); |
| 177 | 177 | return (new driverStatistic()) |
| 178 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 179 | - ->setRawData($info) |
|
| 180 | - ->setSize($info['used_memory']) |
|
| 181 | - ->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))); |
|
| 178 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 179 | + ->setRawData($info) |
|
| 180 | + ->setSize($info['used_memory']) |
|
| 181 | + ->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))); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | \ No newline at end of file |
@@ -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; |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | if ($document) { |
| 110 | 110 | return [ |
| 111 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
| 112 | - self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
| 113 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
| 111 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
| 112 | + self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
| 113 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
| 114 | 114 | ]; |
| 115 | 115 | } else { |
| 116 | 116 | return null; |
@@ -165,10 +165,10 @@ discard block |
||
| 165 | 165 | * @todo make an url builder |
| 166 | 166 | */ |
| 167 | 167 | $this->instance = $this->instance ?: (new MongodbClient('mongodb://' . |
| 168 | - ($username ?: '') . |
|
| 169 | - ($password ? ":{$password}" : '') . |
|
| 170 | - ($username ? '@' : '') . "{$host}" . |
|
| 171 | - ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]))->phpFastCache; |
|
| 168 | + ($username ?: '') . |
|
| 169 | + ($password ? ":{$password}" : '') . |
|
| 170 | + ($username ? '@' : '') . "{$host}" . |
|
| 171 | + ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]))->phpFastCache; |
|
| 172 | 172 | // $this->instance->Cache->createIndex([self::DRIVER_TIME_WRAPPER_INDEX => 1], ['expireAfterSeconds' => 0]); |
| 173 | 173 | } |
| 174 | 174 | } |
@@ -209,25 +209,25 @@ discard block |
||
| 209 | 209 | public function getStats() |
| 210 | 210 | { |
| 211 | 211 | $serverStatus = $this->getCollection()->db->command([ |
| 212 | - 'serverStatus' => 1, |
|
| 213 | - 'recordStats' => 0, |
|
| 214 | - 'repl' => 0, |
|
| 215 | - 'metrics' => 0, |
|
| 212 | + 'serverStatus' => 1, |
|
| 213 | + 'recordStats' => 0, |
|
| 214 | + 'repl' => 0, |
|
| 215 | + 'metrics' => 0, |
|
| 216 | 216 | ]); |
| 217 | 217 | |
| 218 | 218 | $collStats = $this->getCollection()->db->command([ |
| 219 | - 'collStats' => 'Cache', |
|
| 220 | - 'verbose' => true, |
|
| 219 | + 'collStats' => 'Cache', |
|
| 220 | + 'verbose' => true, |
|
| 221 | 221 | ]); |
| 222 | 222 | |
| 223 | 223 | $stats = (new driverStatistic()) |
| 224 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
| 225 | - ->setSize((int) $collStats[ 'size' ]) |
|
| 226 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 227 | - ->setRawData([ |
|
| 224 | + ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
| 225 | + ->setSize((int) $collStats[ 'size' ]) |
|
| 226 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 227 | + ->setRawData([ |
|
| 228 | 228 | 'serverStatus' => $serverStatus, |
| 229 | 229 | 'collStats' => $collStats, |
| 230 | - ]); |
|
| 230 | + ]); |
|
| 231 | 231 | |
| 232 | 232 | return $stats; |
| 233 | 233 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | return false; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
| 95 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
| 96 | 96 | } else { |
| 97 | 97 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
| 98 | 98 | } |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | if ($document) { |
| 110 | 110 | return [ |
| 111 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
| 112 | - self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
| 113 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
| 111 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->bin), |
|
| 112 | + self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_TIME_WRAPPER_INDEX]->sec), |
|
| 113 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->bin), |
|
| 114 | 114 | ]; |
| 115 | 115 | } else { |
| 116 | 116 | return null; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | if ($item instanceof Item) { |
| 131 | 131 | $deletionResult = (array) $this->getCollection()->remove(['_id' => $item->getKey()], ["w" => 1]); |
| 132 | 132 | |
| 133 | - return (int) $deletionResult[ 'ok' ] === 1 && !$deletionResult[ 'err' ]; |
|
| 133 | + return (int) $deletionResult['ok'] === 1 && !$deletionResult['err']; |
|
| 134 | 134 | } else { |
| 135 | 135 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
| 136 | 136 | } |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | if ($this->instance instanceof MongodbClient) { |
| 155 | 155 | throw new LogicException('Already connected to Mongodb server'); |
| 156 | 156 | } else { |
| 157 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
| 158 | - $port = isset($server[ 'port' ]) ? $server[ 'port' ] : '27017'; |
|
| 159 | - $timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : 3; |
|
| 160 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
| 161 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
| 157 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
| 158 | + $port = isset($server['port']) ? $server['port'] : '27017'; |
|
| 159 | + $timeout = isset($server['timeout']) ? $server['timeout'] : 3; |
|
| 160 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
| 161 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
| 162 | 162 | |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | { |
| 192 | 192 | $document = $this->getCollection()->findOne(['_id' => $item->getKey()], [self::DRIVER_TIME_WRAPPER_INDEX /*'d', 'e'*/]); |
| 193 | 193 | if ($document) { |
| 194 | - return $document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec >= time(); |
|
| 194 | + return $document[self::DRIVER_TIME_WRAPPER_INDEX]->sec >= time(); |
|
| 195 | 195 | } else { |
| 196 | 196 | return null; |
| 197 | 197 | } |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | ]); |
| 222 | 222 | |
| 223 | 223 | $stats = (new driverStatistic()) |
| 224 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
| 225 | - ->setSize((int) $collStats[ 'size' ]) |
|
| 224 | + ->setInfo('MongoDB version ' . $serverStatus['version'] . ', Uptime (in days): ' . round($serverStatus['uptime'] / 86400, 1) . "\n For more information see RawData.") |
|
| 225 | + ->setSize((int) $collStats['size']) |
|
| 226 | 226 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 227 | 227 | ->setRawData([ |
| 228 | 228 | 'serverStatus' => $serverStatus, |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | public function driverConnect() |
| 128 | 128 | { |
| 129 | 129 | $server = isset($this->config[ 'redis' ]) ? $this->config[ 'redis' ] : [ |
| 130 | - 'host' => '127.0.0.1', |
|
| 131 | - 'port' => '6379', |
|
| 132 | - 'password' => '', |
|
| 133 | - 'database' => '', |
|
| 130 | + 'host' => '127.0.0.1', |
|
| 131 | + 'port' => '6379', |
|
| 132 | + 'password' => '', |
|
| 133 | + 'database' => '', |
|
| 134 | 134 | ]; |
| 135 | 135 | |
| 136 | 136 | $config = [ |
| 137 | - 'host' => $server[ 'host' ], |
|
| 137 | + 'host' => $server[ 'host' ], |
|
| 138 | 138 | ]; |
| 139 | 139 | |
| 140 | 140 | $port = isset($server[ 'port' ]) ? $server[ 'port' ] : ''; |
@@ -196,8 +196,8 @@ discard block |
||
| 196 | 196 | public function getStats() |
| 197 | 197 | { |
| 198 | 198 | return (new driverStatistic()) |
| 199 | - ->setRawData($this->instance->info()) |
|
| 200 | - ->setSize(0) |
|
| 201 | - ->setInfo(''); |
|
| 199 | + ->setRawData($this->instance->info()) |
|
| 200 | + ->setSize(0) |
|
| 201 | + ->setInfo(''); |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | \ No newline at end of file |
@@ -176,9 +176,9 @@ |
||
| 176 | 176 | public function getStats() |
| 177 | 177 | { |
| 178 | 178 | return (new driverStatistic()) |
| 179 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 180 | - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($this->getLeveldbFile())) |
|
| 181 | - ->setSize(Directory::dirSize($this->getLeveldbFile())); |
|
| 179 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 180 | + ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($this->getLeveldbFile())) |
|
| 181 | + ->setSize(Directory::dirSize($this->getLeveldbFile())); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -142,10 +142,10 @@ discard block |
||
| 142 | 142 | $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
| 143 | 143 | $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
| 144 | 144 | $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
| 145 | - [ |
|
| 145 | + [ |
|
| 146 | 146 | 'bucket' => 'default', |
| 147 | 147 | 'password' => '', |
| 148 | - ], |
|
| 148 | + ], |
|
| 149 | 149 | ]; |
| 150 | 150 | |
| 151 | 151 | $this->instance = $this->instance ?: new CouchbaseClient("couchbase://{$host}", $username, $password); |
@@ -209,9 +209,9 @@ discard block |
||
| 209 | 209 | { |
| 210 | 210 | $info = $this->getBucket()->manager()->info(); |
| 211 | 211 | return (new driverStatistic()) |
| 212 | - ->setSize($info['basicStats']['diskUsed']) |
|
| 213 | - ->setRawData($info) |
|
| 214 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 215 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][0]['version'] . ', Uptime (in days): ' . round($info[ 'nodes' ][0][ 'uptime' ] / 86400, 1). "\n For more information see RawData."); |
|
| 212 | + ->setSize($info['basicStats']['diskUsed']) |
|
| 213 | + ->setRawData($info) |
|
| 214 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 215 | + ->setInfo('CouchBase version ' . $info[ 'nodes' ][0]['version'] . ', Uptime (in days): ' . round($info[ 'nodes' ][0][ 'uptime' ] / 86400, 1). "\n For more information see RawData."); |
|
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | \ No newline at end of file |
@@ -137,11 +137,11 @@ discard block |
||
| 137 | 137 | } else { |
| 138 | 138 | |
| 139 | 139 | |
| 140 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
| 140 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
| 141 | 141 | //$port = isset($server[ 'port' ]) ? $server[ 'port' ] : '11211'; |
| 142 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
| 143 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
| 144 | - $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
|
| 142 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
| 143 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
| 144 | + $buckets = isset($this->config['buckets']) ? $this->config['buckets'] : [ |
|
| 145 | 145 | [ |
| 146 | 146 | 'bucket' => 'default', |
| 147 | 147 | 'password' => '', |
@@ -151,8 +151,8 @@ discard block |
||
| 151 | 151 | $this->instance = $this->instance ?: new CouchbaseClient("couchbase://{$host}", $username, $password); |
| 152 | 152 | |
| 153 | 153 | foreach ($buckets as $bucket) { |
| 154 | - $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ]; |
|
| 155 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ], $bucket[ 'password' ])); |
|
| 154 | + $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket']; |
|
| 155 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'], $bucket['password'])); |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | protected function getBucket() |
| 164 | 164 | { |
| 165 | - return $this->bucketInstances[ $this->bucketCurrent ]; |
|
| 165 | + return $this->bucketInstances[$this->bucketCurrent]; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | protected function setBucket($bucketName, \CouchbaseBucket $CouchbaseBucket) |
| 174 | 174 | { |
| 175 | 175 | if (!array_key_exists($bucketName, $this->bucketInstances)) { |
| 176 | - $this->bucketInstances[ $bucketName ] = $CouchbaseBucket; |
|
| 176 | + $this->bucketInstances[$bucketName] = $CouchbaseBucket; |
|
| 177 | 177 | } else { |
| 178 | 178 | throw new \LogicException('A bucket instance with this name already exists.'); |
| 179 | 179 | } |
@@ -212,6 +212,6 @@ discard block |
||
| 212 | 212 | ->setSize($info['basicStats']['diskUsed']) |
| 213 | 213 | ->setRawData($info) |
| 214 | 214 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 215 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][0]['version'] . ', Uptime (in days): ' . round($info[ 'nodes' ][0][ 'uptime' ] / 86400, 1). "\n For more information see RawData."); |
|
| 215 | + ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, 1) . "\n For more information see RawData."); |
|
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | \ 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 | |
@@ -178,9 +178,9 @@ discard block |
||
| 178 | 178 | $stats = (array) $this->instance->getstats(); |
| 179 | 179 | $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
| 180 | 180 | return (new driverStatistic()) |
| 181 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 182 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
| 183 | - ->setRawData($stats) |
|
| 184 | - ->setSize($stats['bytes']); |
|
| 181 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 182 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
| 183 | + ->setRawData($stats) |
|
| 184 | + ->setSize($stats['bytes']); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | \ No newline at end of file |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE); |
| 153 | 153 | $PDO->setAttribute(PDO::ATTR_ERRMODE, |
| 154 | - PDO::ERRMODE_EXCEPTION); |
|
| 154 | + PDO::ERRMODE_EXCEPTION); |
|
| 155 | 155 | |
| 156 | 156 | if ($createTable == true) { |
| 157 | 157 | $this->initIndexing($PDO); |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | // look for keyword |
| 187 | 187 | $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1"); |
| 188 | 188 | $stm->execute([ |
| 189 | - ':keyword' => $keyword, |
|
| 189 | + ':keyword' => $keyword, |
|
| 190 | 190 | ]); |
| 191 | 191 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 192 | 192 | if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | $db = $this->currentDB; |
| 199 | 199 | $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)"); |
| 200 | 200 | $stm->execute([ |
| 201 | - ':keyword' => $keyword, |
|
| 202 | - ':db' => $db, |
|
| 201 | + ':keyword' => $keyword, |
|
| 202 | + ':db' => $db, |
|
| 203 | 203 | ]); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -270,11 +270,11 @@ discard block |
||
| 270 | 270 | if ($toWrite == true) { |
| 271 | 271 | try { |
| 272 | 272 | $stm = $this->getDb($item->getKey()) |
| 273 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 273 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 274 | 274 | $stm->execute([ |
| 275 | - ':keyword' => $item->getKey(), |
|
| 276 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 277 | - ':exp' => time() + $item->getTtl(), |
|
| 275 | + ':keyword' => $item->getKey(), |
|
| 276 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 277 | + ':exp' => time() + $item->getTtl(), |
|
| 278 | 278 | ]); |
| 279 | 279 | |
| 280 | 280 | return true; |
@@ -282,11 +282,11 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | try { |
| 284 | 284 | $stm = $this->getDb($item->getKey(), true) |
| 285 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 285 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 286 | 286 | $stm->execute([ |
| 287 | - ':keyword' => $item->getKey(), |
|
| 288 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 289 | - ':exp' => time() + $item->getTtl(), |
|
| 287 | + ':keyword' => $item->getKey(), |
|
| 288 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 289 | + ':exp' => time() + $item->getTtl(), |
|
| 290 | 290 | ]); |
| 291 | 291 | } catch (PDOException $e) { |
| 292 | 292 | return false; |
@@ -308,20 +308,20 @@ discard block |
||
| 308 | 308 | { |
| 309 | 309 | try { |
| 310 | 310 | $stm = $this->getDb($key) |
| 311 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
| 311 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
| 312 | 312 | $stm->execute([ |
| 313 | - ':keyword' => $key, |
|
| 314 | - ':U' => time(), |
|
| 313 | + ':keyword' => $key, |
|
| 314 | + ':U' => time(), |
|
| 315 | 315 | ]); |
| 316 | 316 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 317 | 317 | |
| 318 | 318 | } catch (PDOException $e) { |
| 319 | 319 | try { |
| 320 | 320 | $stm = $this->getDb($key, true) |
| 321 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
| 321 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
| 322 | 322 | $stm->execute([ |
| 323 | - ':keyword' => $key, |
|
| 324 | - ':U' => time(), |
|
| 323 | + ':keyword' => $key, |
|
| 324 | + ':U' => time(), |
|
| 325 | 325 | ]); |
| 326 | 326 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 327 | 327 | } catch (PDOException $e) { |
@@ -359,13 +359,13 @@ discard block |
||
| 359 | 359 | if ($item instanceof Item) { |
| 360 | 360 | try { |
| 361 | 361 | $stm = $this->getDb($item->getKey()) |
| 362 | - //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
| 363 | - ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
| 362 | + //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
| 363 | + ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
| 364 | 364 | |
| 365 | 365 | return $stm->execute([ |
| 366 | 366 | // ':id' => $row[ 'id' ], |
| 367 | - ':keyword' => $item->getKey(), |
|
| 368 | - ':U' => time(), |
|
| 367 | + ':keyword' => $item->getKey(), |
|
| 368 | + ':U' => time(), |
|
| 369 | 369 | ]); |
| 370 | 370 | } catch (PDOException $e) { |
| 371 | 371 | return false; |
@@ -423,10 +423,10 @@ discard block |
||
| 423 | 423 | * @todo: Check expiration time here |
| 424 | 424 | */ |
| 425 | 425 | $stm = $this->getDb($item->getKey()) |
| 426 | - ->prepare("SELECT COUNT(`id`) as `total` FROM `caching` WHERE (`keyword`=:keyword) AND (`exp` <= :U) "); |
|
| 426 | + ->prepare("SELECT COUNT(`id`) as `total` FROM `caching` WHERE (`keyword`=:keyword) AND (`exp` <= :U) "); |
|
| 427 | 427 | $stm->execute([ |
| 428 | - ':keyword' => $item->getKey(), |
|
| 429 | - ':U' => time(), |
|
| 428 | + ':keyword' => $item->getKey(), |
|
| 429 | + ':U' => time(), |
|
| 430 | 430 | ]); |
| 431 | 431 | $data = $stm->fetch(PDO::FETCH_ASSOC); |
| 432 | 432 | if ($data[ 'total' ] >= 1) { |
@@ -459,9 +459,9 @@ discard block |
||
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | $stat->setData(implode(', ', array_keys($this->itemInstances))) |
| 462 | - ->setRawData([]) |
|
| 463 | - ->setSize(Directory::dirSize($path)) |
|
| 464 | - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
| 462 | + ->setRawData([]) |
|
| 463 | + ->setSize(Directory::dirSize($path)) |
|
| 464 | + ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
| 465 | 465 | |
| 466 | 466 | return $stat; |
| 467 | 467 | } |