| @@ 158-206 (lines=49) @@ | ||
| 155 | * |
|
| 156 | * @return mixed |
|
| 157 | */ |
|
| 158 | protected function getXattr($name, $time) { |
|
| 159 | ||
| 160 | $cacheFile = $name.".cache"; |
|
| 161 | ||
| 162 | if ( file_exists($cacheFile) ) { |
|
| 163 | ||
| 164 | $expire = xattr_get($cacheFile, "EXPIRE", XATTR_DONTFOLLOW); |
|
| 165 | ||
| 166 | if ( $expire === false ) { |
|
| 167 | ||
| 168 | $this->logger->error("Error reading cache ttl $cacheFile (XATTR), exiting gracefully", pathinfo($cacheFile)); |
|
| 169 | ||
| 170 | $this->setErrorState("Error reading cache ttl $cacheFile (XATTR)"); |
|
| 171 | ||
| 172 | $return = null; |
|
| 173 | ||
| 174 | } else if ( $expire < $time ) { |
|
| 175 | ||
| 176 | $return = null; |
|
| 177 | ||
| 178 | } else { |
|
| 179 | ||
| 180 | $data = file_get_contents($cacheFile); |
|
| 181 | ||
| 182 | if ( $data === false ) { |
|
| 183 | ||
| 184 | $this->logger->error("Error reading cache content $cacheFile, exiting gracefully", pathinfo($cacheFile)); |
|
| 185 | ||
| 186 | $this->setErrorState("Error reading cache content $cacheFile"); |
|
| 187 | ||
| 188 | $return = null; |
|
| 189 | ||
| 190 | } else { |
|
| 191 | ||
| 192 | $return = $data; |
|
| 193 | ||
| 194 | } |
|
| 195 | ||
| 196 | } |
|
| 197 | ||
| 198 | } else { |
|
| 199 | ||
| 200 | $return = null; |
|
| 201 | ||
| 202 | } |
|
| 203 | ||
| 204 | return $return; |
|
| 205 | ||
| 206 | } |
|
| 207 | ||
| 208 | /** |
|
| 209 | * Get a cache element using ghost file |
|
| @@ 216-266 (lines=51) @@ | ||
| 213 | * |
|
| 214 | * @return mixed |
|
| 215 | */ |
|
| 216 | protected function getGhost($name, $time) { |
|
| 217 | ||
| 218 | $cacheFile = $name.".cache"; |
|
| 219 | ||
| 220 | $cacheGhost = $name.".expire"; |
|
| 221 | ||
| 222 | if ( file_exists($cacheFile) ) { |
|
| 223 | ||
| 224 | $expire = file_get_contents($cacheGhost); |
|
| 225 | ||
| 226 | if ( $expire === false ) { |
|
| 227 | ||
| 228 | $this->logger->error("Error reading cache ttl $cacheGhost (GHOST), exiting gracefully", pathinfo($cacheGhost)); |
|
| 229 | ||
| 230 | $this->setErrorState("Error reading cache ttl $cacheGhost (GHOST)"); |
|
| 231 | ||
| 232 | $return = null; |
|
| 233 | ||
| 234 | } else if ( intval($expire) < $time ) { |
|
| 235 | ||
| 236 | $return = null; |
|
| 237 | ||
| 238 | } else { |
|
| 239 | ||
| 240 | $data = file_get_contents($cacheFile); |
|
| 241 | ||
| 242 | if ( $data === false ) { |
|
| 243 | ||
| 244 | $this->logger->error("Error reading cache content $cacheFile, exiting gracefully", pathinfo($cacheFile)); |
|
| 245 | ||
| 246 | $this->setErrorState("Error reading cache content $cacheFile"); |
|
| 247 | ||
| 248 | $return = null; |
|
| 249 | ||
| 250 | } else { |
|
| 251 | ||
| 252 | $return = $data; |
|
| 253 | ||
| 254 | } |
|
| 255 | ||
| 256 | } |
|
| 257 | ||
| 258 | } else { |
|
| 259 | ||
| 260 | $return = null; |
|
| 261 | ||
| 262 | } |
|
| 263 | ||
| 264 | return $return; |
|
| 265 | ||
| 266 | } |
|
| 267 | ||
| 268 | } |
|
| 269 | ||