You are here

protected function RiakCache::doSave in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/doctrine/cache/lib/Doctrine/Common/Cache/RiakCache.php \Doctrine\Common\Cache\RiakCache::doSave()

Puts data into the cache.

Parameters

string $id The cache id.:

string $data The cache entry/data.:

int $lifeTime The lifetime. If != 0, sets a specific lifetime for this: cache entry (0 => infinite lifeTime).

Return value

boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise.

Overrides CacheProvider::doSave

File

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

Class

RiakCache
Riak cache provider.

Namespace

Doctrine\Common\Cache

Code

protected function doSave($id, $data, $lifeTime = 0) {
  try {
    $object = new Object($id);
    $object
      ->setContent(serialize($data));
    if ($lifeTime > 0) {
      $object
        ->addMetadata(self::EXPIRES_HEADER, (string) (time() + $lifeTime));
    }
    $this->bucket
      ->put($object);
    return true;
  } catch (Exception\RiakException $e) {

    // Do nothing
  }
  return false;
}