src/Files.php
/**
     * Retrieves the cache content for the given key.
     *
     * @param  string $key The cache key to retrieve.
     * @return mixed|null Returns the cached data or null.
     */
Retrieves the cache content for the given key.
@param  string $key The cache key to retrieve.
@return mixed|null Returns the cached data or null.
Retrieves the cache content for the given key . @param string $key The cache key to retrieve . @return mixed|null Returns the cached data or null .
public function loadKey($key)
    {
        $key = $this->mapKey($key);
        $path = $this->getOption('directory') . DIRECTORY_SEPARATOR . base64_encode($key);
        if (!file_exists($path) || !is_file($path)) {
            return null;
        }
        $data = $this->readFile($path);
        if ('' === $data) {
            unlink($path);
            return null;
        }
        $pos0 = strpos($data, PHP_EOL, 0);
        if (false === $pos0) {
            unlink($path);
            return null;
        }
        $eolLen = strlen(PHP_EOL);
        $pos = strpos($data, PHP_EOL, $pos0+$eolLen);
        if (false === $pos) {
            unlink($path);
            return null;
        }
        $expire = (int)substr($data, $pos0 + $eolLen, $pos - $pos0 - $eolLen);
        if ($expire != 0 && ($expire - time() < 0)) { 
            unlink($path);
            return null;
        }
        $serialized = substr($data, $pos+$eolLen);
        return unserialize($serialized);
    }
public function loadKey ( $ key ) { $ key = $ this -> mapKey ( $ key ) ; $ path = $ this -> getOption ( 'directory' ) . DIRECTORY_SEPARATOR . base64_encode ( $ key ) ; if ( ! file_exists ( $ path ) || ! is_file ( $ path ) ) { return null ; } $ data = $ this -> readFile ( $ path ) ; if ( '' === $ data ) { unlink ( $ path ) ; return null ; } $ pos0 = strpos ( $ data , PHP_EOL , 0 ) ; if ( false === $ pos0 ) { unlink ( $ path ) ; return null ; } $ eolLen = strlen ( PHP_EOL ) ; $ pos = strpos ( $ data , PHP_EOL , $ pos0 + $ eolLen ) ; if ( false === $ pos ) { unlink ( $ path ) ; return null ; } $ expire = ( int ) substr ( $ data , $ pos0 + $ eolLen , $ pos - $ pos0 - $ eolLen ) ; if ( $ expire != 0 && ( $ expire - time ( ) < 0 ) ) { unlink ( $ path ) ; return null ; } $ serialized = substr ( $ data , $ pos + $ eolLen ) ; return unserialize ( $ serialized ) ; }
Retrieves the cache content for the given key.
Retrieves the cache content for the given key .
// Un-complete file // Un-complete file // expired