Fetch the cached content

@param string $id cache id (e.g. a filename)

@return string
183245
public function fetch($id)
    {
        if (!$this->locking) {
            return file_get_contents($this->path . '/' . $id);
        }

        $fp = fopen($this->path . '/' . $id, 'rb');
        if (!$fp) {
            return false;
        }

        flock($fp, LOCK_SH);
        $ret = stream_get_contents($fp);
        flock($fp, LOCK_UN);
        fclose($fp);

        return $ret;
    }
1008407
public function findDocument($id)
    {
        $documentPath = '/'.$this->databaseName.'/'.urlencode($id);

        return $this->httpClient->request('GET', $documentPath);
    }
237149
public function fetch($id)
    {
        // Bail out if a non-string was passed.
        if (!is_string($id)) {
            throw Object_Freezer_Util::getInvalidArgumentException(1, 'string');
        }

        // Try to retrieve object from the object cache.
        $object = $this->cache->get($id);

        if (!$object) {
            // Retrieve object from the object storage.
            $frozenObject = $this->doFetch($id);
            $this->fetchArray($frozenObject['objects'][$id]['state']);
            $object = $this->freezer->thaw($frozenObject);

            // Put object into the object cache.
            $this->cache->put($id, $object);
        }

        return $object;
    }
404083
public function read($id)
    {
        // Check if id exists
        if (!xcache_isset($this->prefix . $id)) {
            return false;
        }

        return (string) xcache_get($this->prefix . $id);
    }
807478
protected static function getCache($id)
    {
        $type = static::getType();

        $id = (string)$id;

        static::initializeCache($type);

        $collection = self::$cache->{$type};

        if (!property_exists($collection, $id)) {
            return null;
        }

        $resource = $collection->{$id};

        return (clone $resource);
    }
668747
protected function getFileName($id)
    {
        $directory = $this->getDirectory($id);
        $hash      = sha1($id, false);
        $file      = $directory . DIRECTORY_SEPARATOR . $hash . '.cache';
        return $file;
    }
582149
protected function _file($id)
    {
        $instance = self::getInstance();
        $fileNmae = $instance->_idToFileName($id);
        return self::cacheDir() . $fileNmae;
    }
1207821
public function findInResById($id)
    {
        $id = Lib::toInteger($id);
        $this->ensureIdIsInteger($id);

        // Sestaveni URL
        $url = $this->wrapUrl(sprintf(self::URL_RES, $id));

        $cachedFileName = $id.'_'.date($this->cacheStrategy).'.php';
        $cachedFile = $this->cacheDir.'/res_'.$cachedFileName;
        $cachedRawFile = $this->cacheDir.'/res_raw_'.$cachedFileName;

        if (is_file($cachedFile)) {
            return unserialize(file_get_contents($cachedFile));
        }

        try {
            $aresRequest = file_get_contents($url, null, stream_context_create($this->contextOptions));
            if ($this->debug) {
                file_put_contents($cachedRawFile, $aresRequest);
            }
            $aresResponse = simplexml_load_string($aresRequest);

            if ($aresResponse) {
                $ns = $aresResponse->getDocNamespaces();
                $data = $aresResponse->children($ns['are']);
                $elements = $data->children($ns['D'])->Vypis_RES;

                if (strval($elements->ZAU->ICO) === $id) {
                    $record = new AresRecord();
                    $record->setCompanyId(strval($id));
                    $record->setTaxId($this->findVatById($id));
                    $record->setCompanyName(strval($elements->ZAU->OF));
                    $record->setStreet(strval($elements->SI->NU));
                    $record->setStreetHouseNumber(strval($elements->SI->CD));
                    $record->setStreetOrientationNumber(strval($elements->SI->CO));
                    $record->setTown(strval($elements->SI->N));
                    $record->setZip(strval($elements->SI->PSC));
                } else {
                    throw new AresException('IČ firmy nebylo nalezeno.');
                }
            } else {
                throw new AresException('Databáze ARES není dostupná.');
            }
        } catch (\Exception $e) {
            throw new AresException($e->getMessage());
        }
        file_put_contents($cachedFile, serialize($record));

        return $record;
    }
52789
protected function getDirectory($id)
    {
        $hash = sha1($id, false);
        $dirs = array(
            $this->getCacheDirectory(),
            substr($hash, 0, 2),
            substr($hash, 2, 2)
        );
        return join(DIRECTORY_SEPARATOR, $dirs);
    }
668735
public static function get( $id ) {
		if ( file_exists( Utils\get_snapshot_directory() . $id . '/meta.json' ) ) {
			$meta_file_contents = file_get_contents( Utils\get_snapshot_directory() . $id . '/meta.json' );
			$meta               = json_decode( $meta_file_contents, true );
		} else {
			$meta = [];
		}

		/**
		 * Backwards compant - need to fill in repo before we started saving repo in meta.
		 */
		if ( empty( $meta['repository'] ) ) {
			Log::instance()->write( 'Legacy snapshot found without repository. Assuming default repository.', 1, 'warning' );

			$meta['repository'] = RepositoryManager::instance()->getDefault();
		}

		return new self( $id, $meta['repository'], $meta );
	}
314971
static function get_manager( $id ) {
            $id = strtolower( $id );

            if ( ! isset( self::$_MANAGERS[ $id ] ) ) {
                self::$_MANAGERS[ $id ] = new FS_Cache_Manager( $id );
            }

            return self::$_MANAGERS[ $id ];
        }
131727
public function getDownload4Id($id)
    {
        $query = $this->createQueryBuilder('p')
            ->select('p')
            ->where('p.id = :id')
            ->setParameter('id', $id)
            ->setMaxResults(1)
            ->getQuery();

        return $query->getOneOrNullResult();
    }
73642
protected function _loadMetadatas($id)
    {
        $file = $this->_metadatasFile($id);
        $result = $this->_fileGetContents($file);
        if (!$result) {
            return false;
        }
        $tmp = @unserialize($result);
        return $tmp;
    }
328579
public function get(string $id = null): array
    {
        if ($this->has($id)) {
            return $this->cache[$id];
        }

        return [];
    }
679539
static function fetch( $id )
    {
        $cond = array( 'id' => $id );
        $return = eZPersistentObject::fetchObject( self::definition(), null, $cond );
        return $return;
    }
641170
public function findVatById($id)
    {
        $id = Lib::toInteger($id);

        $this->ensureIdIsInteger($id);

        // Sestaveni URL
        $url = $this->wrapUrl(sprintf(self::URL_TAX, $id));

        $cachedFileName = $id.'_'.date($this->cacheStrategy).'.php';
        $cachedFile = $this->cacheDir.'/tax_'.$cachedFileName;
        $cachedRawFile = $this->cacheDir.'/tax_raw_'.$cachedFileName;

        if (is_file($cachedFile)) {
            return unserialize(file_get_contents($cachedFile));
        }

        try {
            $vatRequest = file_get_contents($url, null, stream_context_create($this->contextOptions));
            if ($this->debug) {
                file_put_contents($cachedRawFile, $vatRequest);
            }
            $vatResponse = simplexml_load_string($vatRequest);

            if ($vatResponse) {
                $record = new TaxRecord();
                $ns = $vatResponse->getDocNamespaces();
                $data = $vatResponse->children($ns['are']);
                $elements = $data->children($ns['dtt'])->V->S;

                if (strval($elements->ico) === $id) {
                    $record->setTaxId(str_replace('dic=', 'CZ', strval($elements->p_dph)));
                } else {
                    throw new AresException('DIČ firmy nebylo nalezeno.');
                }
            } else {
                throw new AresException('Databáze MFČR není dostupná.');
            }
        } catch (\Exception $e) {
            throw new \Exception($e->getMessage());
        }
        file_put_contents($cachedFile, serialize($record));

        return $record;
    }
1192196
public function get($id)
    {
        $file_name = $this->getFileName($id);

        if (!is_file($file_name) || !is_readable($file_name)) {
            return false;
        }

        $lines    = file($file_name);
        $lifetime = array_shift($lines);
        $lifetime = (int) trim($lifetime);

        if ($lifetime !== 0 && $lifetime < time()) {
            @unlink($file_name);
            return false;
        }
        $serialized = join('', $lines);
        $data       = unserialize($serialized);
        return $data;
    }