public function fetch($request)
    {
        if (!$this->exists($request)) {
            return;
        }

        $manifest = null;
        foreach ($this->entries as $index => $entry) {
            if ($entry['sourceFile'] === $request['file']->getPathname()) {
                $manifest = $entry;
                break;  // we found entry in cache corresponding to current filename
            }
        }

        if (!isset($manifest)) {
            // no cache results for this filename
            return;
        }

        // Ensure that the response is not expired
        if ($manifest['expiration'] < time()
            || $manifest['cacheData'] !== sha1_file($request['file']->getPathname())
        ) {
            // results have expired
            $response = false;
        } else {
            $response = $this->cache->fetch($manifest['cacheData']);
        }

        if ($response === false) {
            // Remove the entry from the metadata and update the cache
            unset($this->entries[$index]);
            if (count($this->entries)) {
                $this->cache->save($this->key, $this->entries);
            } else {
                $this->cache->delete($this->key);
            }
        }

        return $response;
    }
public function fetch($request)
    {
        if (!$this->exists($request)) {
            return;
        }

        $manifest = null;
        foreach ($this->entries as $index => $entry) {
            if ($entry['sourceFile'] === $request['file']->getPathname()) {
                $manifest = $entry;
                break;  // we found entry in cache corresponding to current filename
            }
        }

        if (!isset($manifest)) {
            // no cache results for this filename
            return;
        }

        // Ensure that the response is not expired
        if ($manifest['expiration'] < time()
            || $manifest['cacheData'] !== sha1_file($request['file']->getPathname())
        ) {
            // results have expired
            $response = false;
        } else {
            $response = $this->cache->fetch($manifest['cacheData']);
        }

        if ($response === false) {
            // Remove the entry from the metadata and update the cache
            unset($this->entries[$index]);
            if (count($this->entries)) {
                $this->cache->save($this->key, $this->entries);
            } else {
                $this->cache->delete($this->key);
            }
        }

        return $response;
    }
public function fetch ( $ request ) { if ( ! $ this -> exists ( $ request ) ) { return ; } $ manifest = null ; foreach ( $ this -> entries as $ index => $ entry ) { if ( $ entry [ 'sourceFile' ] === $ request [ 'file' ] -> getPathname ( ) ) { $ manifest = $ entry ; break ; // we found entry in cache corresponding to current filename } } if ( ! isset ( $ manifest ) ) { // no cache results for this filename return ; } // Ensure that the response is not expired if ( $ manifest [ 'expiration' ] < time ( ) || $ manifest [ 'cacheData' ] !== sha1_file ( $ request [ 'file' ] -> getPathname ( ) ) ) { // results have expired $ response = false ; } else { $ response = $ this -> cache -> fetch ( $ manifest [ 'cacheData' ] ) ; } if ( $ response === false ) { // Remove the entry from the metadata and update the cache unset ( $ this -> entries [ $ index ] ) ; if ( count ( $ this -> entries ) ) { $ this -> cache -> save ( $ this -> key , $ this -> entries ) ; } else { $ this -> cache -> delete ( $ this -> key ) ; } } return $ response ; }
Get a response from the cache for a request.

@param array $request Request data to read from cache

@return mixed
Get a response from the cache for a request .