You are here

protected function RiakCache::doFetch in Plug 7

Fetches an entry from the cache.

Parameters

string $id The id of the cache entry to fetch.:

Return value

string|boolean The cached data or FALSE, if no cache entry exists for the given id.

Overrides CacheProvider::doFetch

File

lib/doctrine/cache/lib/Doctrine/Common/Cache/RiakCache.php, line 57

Class

RiakCache
Riak cache provider.

Namespace

Doctrine\Common\Cache

Code

protected function doFetch($id) {
  try {
    $response = $this->bucket
      ->get($id);

    // No objects found
    if (!$response
      ->hasObject()) {
      return false;
    }

    // Check for attempted siblings
    $object = $response
      ->hasSiblings() ? $this
      ->resolveConflict($id, $response
      ->getVClock(), $response
      ->getObjectList()) : $response
      ->getFirstObject();

    // Check for expired object
    if ($this
      ->isExpired($object)) {
      $this->bucket
        ->delete($object);
      return false;
    }
    return unserialize($object
      ->getContent());
  } catch (Exception\RiakException $e) {

    // Covers:
    // - Riak\ConnectionException
    // - Riak\CommunicationException
    // - Riak\UnexpectedResponseException
    // - Riak\NotFoundException
  }
  return false;
}