@@ -120,9 +120,9 @@ |
||
| 120 | 120 | { |
| 121 | 121 | $this->connectServer(); |
| 122 | 122 | $res = array( |
| 123 | - 'info' => '', |
|
| 124 | - 'size' => '', |
|
| 125 | - 'data' => $_COOKIE, |
|
| 123 | + 'info' => '', |
|
| 124 | + 'size' => '', |
|
| 125 | + 'data' => $_COOKIE, |
|
| 126 | 126 | ); |
| 127 | 127 | |
| 128 | 128 | return $res; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function __construct($config = array()) |
| 30 | 30 | { |
| 31 | 31 | $this->setup($config); |
| 32 | - if (!$this->checkdriver() && !isset($config[ 'skipError' ])) { |
|
| 32 | + if (!$this->checkdriver() && !isset($config['skipError'])) { |
|
| 33 | 33 | $this->fallback = true; |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | public function connectServer() |
| 54 | 54 | { |
| 55 | 55 | // for cookie check output |
| 56 | - if (!isset($_COOKIE[ 'phpFastCache' ])) { |
|
| 56 | + if (!isset($_COOKIE['phpFastCache'])) { |
|
| 57 | 57 | if (!@setcookie('phpFastCache', 1, 10)) { |
| 58 | 58 | $this->fallback = true; |
| 59 | 59 | } |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | $this->connectServer(); |
| 74 | 74 | $keyword = 'phpFastCache_' . $keyword; |
| 75 | 75 | $v = $this->encode($value); |
| 76 | - if(isset($this->config['limited_memory_each_object']) |
|
| 76 | + if (isset($this->config['limited_memory_each_object']) |
|
| 77 | 77 | && strlen($v) > $this->config['limited_memory_each_object']) { |
| 78 | 78 | return false; |
| 79 | 79 | } |
| 80 | - return setcookie($keyword, $v, time() + ($time ? (int)$time : 300), '/'); |
|
| 80 | + return setcookie($keyword, $v, time() + ($time ? (int) $time : 300), '/'); |
|
| 81 | 81 | |
| 82 | 82 | } |
| 83 | 83 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | // return null if no caching |
| 93 | 93 | // return value if in caching |
| 94 | 94 | $keyword = 'phpFastCache_' . $keyword; |
| 95 | - $x = isset($_COOKIE[ $keyword ]) ? $this->decode($_COOKIE[ $keyword ]) : false; |
|
| 95 | + $x = isset($_COOKIE[$keyword]) ? $this->decode($_COOKIE[$keyword]) : false; |
|
| 96 | 96 | if ($x == false) { |
| 97 | 97 | return null; |
| 98 | 98 | } else { |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $this->connectServer(); |
| 110 | 110 | $keyword = 'phpFastCache_' . $keyword; |
| 111 | 111 | @setcookie($keyword, null, -10); |
| 112 | - $_COOKIE[ $keyword ] = null; |
|
| 112 | + $_COOKIE[$keyword] = null; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | foreach ($_COOKIE as $keyword => $value) { |
| 138 | 138 | if (strpos($keyword, 'phpFastCache') !== false) { |
| 139 | 139 | @setcookie($keyword, null, -10); |
| 140 | - $_COOKIE[ $keyword ] = null; |
|
| 140 | + $_COOKIE[$keyword] = null; |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | * @return array|bool |
| 59 | 59 | */ |
| 60 | 60 | public function driver_set( |
| 61 | - $keyword, |
|
| 62 | - $value = '', |
|
| 63 | - $time = 300, |
|
| 64 | - $option = array() |
|
| 61 | + $keyword, |
|
| 62 | + $value = '', |
|
| 63 | + $time = 300, |
|
| 64 | + $option = array() |
|
| 65 | 65 | ) { |
| 66 | 66 | if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true) { |
| 67 | 67 | return apc_add($keyword, $value, $time); |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | public function driver_stats($option = array()) |
| 103 | 103 | { |
| 104 | 104 | $res = array( |
| 105 | - 'info' => '', |
|
| 106 | - 'size' => '', |
|
| 107 | - 'data' => '', |
|
| 105 | + 'info' => '', |
|
| 106 | + 'size' => '', |
|
| 107 | + 'data' => '', |
|
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | 110 | try { |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $time = 300, |
| 64 | 64 | $option = array() |
| 65 | 65 | ) { |
| 66 | - if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true) { |
|
| 66 | + if (isset($option['skipExisting']) && $option['skipExisting'] == true) { |
|
| 67 | 67 | return apc_add($keyword, $value, $time); |
| 68 | 68 | } else { |
| 69 | 69 | return apc_store($keyword, $value, $time); |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | 110 | try { |
| 111 | - $res[ 'data' ] = apc_cache_info('user'); |
|
| 111 | + $res['data'] = apc_cache_info('user'); |
|
| 112 | 112 | } catch (\Exception $e) { |
| 113 | - $res[ 'data' ] = array(); |
|
| 113 | + $res['data'] = array(); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | return $res; |
@@ -79,9 +79,9 @@ |
||
| 79 | 79 | |
| 80 | 80 | if (!isset(self::$hit[ $instance ])) { |
| 81 | 81 | self::$hit[ $instance ] = array( |
| 82 | - "class" => $class, |
|
| 83 | - "storage" => $storage, |
|
| 84 | - "data" => array(), |
|
| 82 | + "class" => $class, |
|
| 83 | + "storage" => $storage, |
|
| 84 | + "data" => array(), |
|
| 85 | 85 | ); |
| 86 | 86 | if ($config[ 'cache_method' ] == 4) { |
| 87 | 87 | register_shutdown_function('phpFastCache\CacheManager::cleanCachingMethod', null); |
@@ -51,47 +51,47 @@ discard block |
||
| 51 | 51 | if (empty($config)) { |
| 52 | 52 | $config = phpFastCache::$config; |
| 53 | 53 | } |
| 54 | - if (!isset($config[ 'cache_method' ])) { |
|
| 55 | - $config[ 'cache_method' ] = phpFastCache::$config[ 'cache_method' ]; |
|
| 54 | + if (!isset($config['cache_method'])) { |
|
| 55 | + $config['cache_method'] = phpFastCache::$config['cache_method']; |
|
| 56 | 56 | } |
| 57 | - if (!isset($config[ 'limited_memory_each_object' ])) { |
|
| 58 | - $config[ 'limited_memory_each_object' ] = phpFastCache::$config[ 'limited_memory_each_object' ]; |
|
| 57 | + if (!isset($config['limited_memory_each_object'])) { |
|
| 58 | + $config['limited_memory_each_object'] = phpFastCache::$config['limited_memory_each_object']; |
|
| 59 | 59 | } |
| 60 | - if (isset(phpFastCache::$config[ 'overwrite' ]) && !in_array(phpFastCache::$config[ 'overwrite' ], array('auto', ''), true)) { |
|
| 61 | - phpFastCache::$config[ 'storage' ] = phpFastCache::$config[ 'overwrite' ]; |
|
| 62 | - $storage = phpFastCache::$config[ 'overwrite' ]; |
|
| 63 | - } else if (isset(phpFastCache::$config[ 'storage' ]) && !in_array(phpFastCache::$config[ 'storage' ], array('auto', ''), true)) { |
|
| 64 | - $storage = phpFastCache::$config[ 'storage' ]; |
|
| 60 | + if (isset(phpFastCache::$config['overwrite']) && !in_array(phpFastCache::$config['overwrite'], array('auto', ''), true)) { |
|
| 61 | + phpFastCache::$config['storage'] = phpFastCache::$config['overwrite']; |
|
| 62 | + $storage = phpFastCache::$config['overwrite']; |
|
| 63 | + } else if (isset(phpFastCache::$config['storage']) && !in_array(phpFastCache::$config['storage'], array('auto', ''), true)) { |
|
| 64 | + $storage = phpFastCache::$config['storage']; |
|
| 65 | 65 | } else if (in_array($storage, array('auto', ''), true)) { |
| 66 | 66 | $storage = phpFastCache::getAutoClass($config); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // echo $storage."<br>"; |
| 70 | 70 | $instance = md5(serialize($config) . $storage); |
| 71 | - if (!isset(self::$instances[ $instance ]) || is_null(self::$instances[ $instance ])) { |
|
| 71 | + if (!isset(self::$instances[$instance]) || is_null(self::$instances[$instance])) { |
|
| 72 | 72 | $class = '\phpFastCache\Drivers\\' . $storage; |
| 73 | - $config[ 'storage' ] = $storage; |
|
| 74 | - $config[ 'instance' ] = $instance; |
|
| 75 | - $config[ 'class' ] = $class; |
|
| 76 | - if (!isset(self::$memory[ $instance ])) { |
|
| 77 | - self::$memory[ $instance ] = array(); |
|
| 73 | + $config['storage'] = $storage; |
|
| 74 | + $config['instance'] = $instance; |
|
| 75 | + $config['class'] = $class; |
|
| 76 | + if (!isset(self::$memory[$instance])) { |
|
| 77 | + self::$memory[$instance] = array(); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if (!isset(self::$hit[ $instance ])) { |
|
| 81 | - self::$hit[ $instance ] = array( |
|
| 80 | + if (!isset(self::$hit[$instance])) { |
|
| 81 | + self::$hit[$instance] = array( |
|
| 82 | 82 | "class" => $class, |
| 83 | 83 | "storage" => $storage, |
| 84 | 84 | "data" => array(), |
| 85 | 85 | ); |
| 86 | - if ($config[ 'cache_method' ] == 4) { |
|
| 86 | + if ($config['cache_method'] == 4) { |
|
| 87 | 87 | register_shutdown_function('phpFastCache\CacheManager::cleanCachingMethod', null); |
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - self::$instances[ $instance ] = new $class($config); |
|
| 91 | + self::$instances[$instance] = new $class($config); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - return self::$instances[ $instance ]; |
|
| 94 | + return self::$instances[$instance]; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -102,13 +102,13 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | $string = strtolower($string); |
| 104 | 104 | if (in_array($string, array("normal", "traditional"))) { |
| 105 | - phpFastCache::$config[ 'cache_method' ] = 1; |
|
| 105 | + phpFastCache::$config['cache_method'] = 1; |
|
| 106 | 106 | } else if (in_array($string, array("fast", "memory"))) { |
| 107 | - phpFastCache::$config[ 'cache_method' ] = 2; |
|
| 107 | + phpFastCache::$config['cache_method'] = 2; |
|
| 108 | 108 | } else if (in_array($string, array("fastest", "phpfastcache"))) { |
| 109 | - phpFastCache::$config[ 'cache_method' ] = 3; |
|
| 109 | + phpFastCache::$config['cache_method'] = 3; |
|
| 110 | 110 | } else if (in_array($string, array("superfast", "phpfastcachex"))) { |
| 111 | - phpFastCache::$config[ 'cache_method' ] = 4; |
|
| 111 | + phpFastCache::$config['cache_method'] = 4; |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
@@ -121,11 +121,11 @@ discard block |
||
| 121 | 121 | public static function __callStatic($name, $arguments) |
| 122 | 122 | { |
| 123 | 123 | $driver = strtolower($name); |
| 124 | - if (!isset(self::$instances[ 'loaded' ][ $driver ]) && class_exists("\\phpFastCache\\Drivers\\{$driver}")) { |
|
| 125 | - self::$instances[ 'loaded' ][ $driver ] = true; |
|
| 124 | + if (!isset(self::$instances['loaded'][$driver]) && class_exists("\\phpFastCache\\Drivers\\{$driver}")) { |
|
| 125 | + self::$instances['loaded'][$driver] = true; |
|
| 126 | 126 | } |
| 127 | - if (isset(self::$instances[ 'loaded' ][ $driver ])) { |
|
| 128 | - return self::getInstance($name, (isset($arguments[ 0 ]) ? $arguments[ 0 ] : array())); |
|
| 127 | + if (isset(self::$instances['loaded'][$driver])) { |
|
| 128 | + return self::getInstance($name, (isset($arguments[0]) ? $arguments[0] : array())); |
|
| 129 | 129 | } else { |
| 130 | 130 | return call_user_func_array(array(self::getInstance(), $name), $arguments); |
| 131 | 131 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | protected static function __CleanCachingMethod($instance) |
| 162 | 162 | { |
| 163 | - if(is_array(self::$memory[ $instance ]) && !empty(self::$memory[ $instance ])) { |
|
| 163 | + if (is_array(self::$memory[$instance]) && !empty(self::$memory[$instance])) { |
|
| 164 | 164 | $old = self::$instances[$instance]->config['cache_method']; |
| 165 | 165 | self::$instances[$instance]->config['cache_method'] = 1; |
| 166 | 166 | foreach (self::$memory[$instance] as $keyword => $object) { |