Cachearium\Backend\CacheRAM::store PHP Method

store() public method

public store ( $data, CacheKey $k, $lifetime )
$k Cachearium\CacheKey
    public function store($data, CacheKey $k, $lifetime = 0)
    {
        // @codeCoverageIgnoreStart
        if (!$this->enabled) {
            return false;
        }
        // @codeCoverageIgnoreEnd
        if (!is_string($k->sub)) {
            $sub = md5(serialize($k->sub));
        } else {
            $sub = $k->sub;
        }
        $this->checkValidArgs($k);
        $this->storage[$this->namespace . $k->base . $k->id][$sub] = $data;
        return true;
    }

Usage Example

 /**
  * (non-PHPdoc)
  * @see \Cachearium\Backend\CacheRAM::store()
  */
 public function store($data, CacheKey $k, $lifetime = 0)
 {
     // @codeCoverageIgnoreStart
     if (!$this->enabled) {
         return false;
     }
     // @codeCoverageIgnoreEnd
     $group = $this->hashKey($k);
     $this->log(CacheLogEnum::SAVED, $k);
     $x = $this->memcached->set($group, serialize($data), $lifetime ? $lifetime : $this->lifetime);
     parent::store($data, $k, $lifetime);
     return $x;
 }