@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | * @var array |
| 53 | 53 | */ |
| 54 | 54 | protected static $config = [ |
| 55 | - 'securityKey' => 'auto',// The securityKey that will be used to create sub-directory |
|
| 56 | - 'htaccess' => true,// Auto-generate .htaccess if tit is missing |
|
| 55 | + 'securityKey' => 'auto', // The securityKey that will be used to create sub-directory |
|
| 56 | + 'htaccess' => true, // Auto-generate .htaccess if tit is missing |
|
| 57 | 57 | 'default_chmod' => 0777, // 0777 recommended |
| 58 | - 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
| 58 | + 'path' => '', // if not set will be the value of sys_get_temp_dir() |
|
| 59 | 59 | 'fallback' => false, //Fall back when old driver is not support |
| 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 |
@@ -90,27 +90,27 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $instance = crc32($driver . serialize($config)); |
| 93 | - if (!isset(self::$instances[ $instance ])) { |
|
| 93 | + if (!isset(self::$instances[$instance])) { |
|
| 94 | 94 | $badPracticeOmeter[$driver] = 1; |
| 95 | 95 | $class = self::getNamespacePath() . $driver . '\Driver'; |
| 96 | - try{ |
|
| 97 | - self::$instances[ $instance ] = new $class($config); |
|
| 98 | - }catch(phpFastCacheDriverCheckException $e){ |
|
| 96 | + try { |
|
| 97 | + self::$instances[$instance] = new $class($config); |
|
| 98 | + } catch (phpFastCacheDriverCheckException $e) { |
|
| 99 | 99 | $fallback = self::standardizeDriverName($config['fallback']); |
| 100 | - if($fallback && $fallback !== $driver){ |
|
| 100 | + if ($fallback && $fallback !== $driver) { |
|
| 101 | 101 | $class = self::getNamespacePath() . $fallback . '\Driver'; |
| 102 | - self::$instances[ $instance ] = new $class($config); |
|
| 102 | + self::$instances[$instance] = new $class($config); |
|
| 103 | 103 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING); |
| 104 | - }else{ |
|
| 104 | + } else { |
|
| 105 | 105 | throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | - } else if(++$badPracticeOmeter[$driver] >= 5){ |
|
| 108 | + } else if (++$badPracticeOmeter[$driver] >= 5) { |
|
| 109 | 109 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
| 110 | 110 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - return self::$instances[ $instance ]; |
|
| 113 | + return self::$instances[$instance]; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public static function __callStatic($name, $arguments) |
| 145 | 145 | { |
| 146 | - $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[ 0 ] : []); |
|
| 146 | + $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[0] : []); |
|
| 147 | 147 | |
| 148 | 148 | return self::getInstance($name, $options); |
| 149 | 149 | } |
@@ -196,9 +196,9 @@ discard block |
||
| 196 | 196 | { |
| 197 | 197 | if (is_array($name)) { |
| 198 | 198 | self::$config = array_merge(self::$config, $name); |
| 199 | - } else if (is_string($name)){ |
|
| 200 | - self::$config[ $name ] = $value; |
|
| 201 | - }else{ |
|
| 199 | + } else if (is_string($name)) { |
|
| 200 | + self::$config[$name] = $value; |
|
| 201 | + } else { |
|
| 202 | 202 | throw new \InvalidArgumentException('Invalid variable type: $name'); |
| 203 | 203 | } |
| 204 | 204 | } |
@@ -95,13 +95,13 @@ discard block |
||
| 95 | 95 | $class = self::getNamespacePath() . $driver . '\Driver'; |
| 96 | 96 | try{ |
| 97 | 97 | self::$instances[ $instance ] = new $class($config); |
| 98 | - }catch(phpFastCacheDriverCheckException $e){ |
|
| 98 | + } catch(phpFastCacheDriverCheckException $e){ |
|
| 99 | 99 | $fallback = self::standardizeDriverName($config['fallback']); |
| 100 | 100 | if($fallback && $fallback !== $driver){ |
| 101 | 101 | $class = self::getNamespacePath() . $fallback . '\Driver'; |
| 102 | 102 | self::$instances[ $instance ] = new $class($config); |
| 103 | 103 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING); |
| 104 | - }else{ |
|
| 104 | + } else{ |
|
| 105 | 105 | throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | self::$config = array_merge(self::$config, $name); |
| 199 | 199 | } else if (is_string($name)){ |
| 200 | 200 | self::$config[ $name ] = $value; |
| 201 | - }else{ |
|
| 201 | + } else{ |
|
| 202 | 202 | throw new \InvalidArgumentException('Invalid variable type: $name'); |
| 203 | 203 | } |
| 204 | 204 | } |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | * @var array |
| 52 | 52 | */ |
| 53 | 53 | protected static $config = [ |
| 54 | - 'securityKey' => 'auto',// The securityKey that will be used to create sub-directory |
|
| 55 | - 'htaccess' => true,// Auto-generate .htaccess if tit is missing |
|
| 56 | - 'default_chmod' => 0777, // 0777 recommended |
|
| 57 | - 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
| 58 | - 'fallback' => false, //Fall back when old driver is not support |
|
| 59 | - 'limited_memory_each_object' => 4096, // maximum size (bytes) of object store in memory |
|
| 60 | - 'compress_data' => false, // compress stored data, if the backend supports it |
|
| 54 | + 'securityKey' => 'auto',// The securityKey that will be used to create sub-directory |
|
| 55 | + 'htaccess' => true,// Auto-generate .htaccess if tit is missing |
|
| 56 | + 'default_chmod' => 0777, // 0777 recommended |
|
| 57 | + 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
| 58 | + 'fallback' => false, //Fall back when old driver is not support |
|
| 59 | + 'limited_memory_each_object' => 4096, // maximum size (bytes) of object store in memory |
|
| 60 | + 'compress_data' => false, // compress stored data, if the backend supports it |
|
| 61 | 61 | ]; |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | } else if(++$badPracticeOmeter[$driver] >= 5){ |
| 108 | - trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
|
| 108 | + trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
|
| 109 | 109 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -218,21 +218,21 @@ discard block |
||
| 218 | 218 | public static function getStaticSystemDrivers() |
| 219 | 219 | { |
| 220 | 220 | return [ |
| 221 | - 'Sqlite', |
|
| 222 | - 'Files', |
|
| 223 | - 'Apc', |
|
| 224 | - 'Apcu', |
|
| 225 | - 'Memcache', |
|
| 226 | - 'Memcached', |
|
| 227 | - 'Couchbase', |
|
| 228 | - 'Mongodb', |
|
| 229 | - 'Predis', |
|
| 230 | - 'Redis', |
|
| 231 | - 'Ssdb', |
|
| 232 | - 'Leveldb', |
|
| 233 | - 'Wincache', |
|
| 234 | - 'Xcache', |
|
| 235 | - 'Devnull', |
|
| 221 | + 'Sqlite', |
|
| 222 | + 'Files', |
|
| 223 | + 'Apc', |
|
| 224 | + 'Apcu', |
|
| 225 | + 'Memcache', |
|
| 226 | + 'Memcached', |
|
| 227 | + 'Couchbase', |
|
| 228 | + 'Mongodb', |
|
| 229 | + 'Predis', |
|
| 230 | + 'Redis', |
|
| 231 | + 'Ssdb', |
|
| 232 | + 'Leveldb', |
|
| 233 | + 'Wincache', |
|
| 234 | + 'Xcache', |
|
| 235 | + 'Devnull', |
|
| 236 | 236 | ]; |
| 237 | 237 | } |
| 238 | 238 | |