Back to MemcachedStorage class

Method store

public bool
store
(mixed $id, mixed $group, mixed $data)
Store the data to cache by ID and group
Parameters
  • string $id The cache data ID
  • string $group The cache data group
  • string $data The data to store in cache
Returns
  • bool
Since
  • 3.0.0

Method store - Source code

/**
 * Store the data to cache by ID and group
 *
 * @param   string  $id     The cache data ID
 * @param   string  $group  The cache data group
 * @param   string  $data   The data to store in cache
 *
 * @return  boolean
 *
 * @since   3.0.0
 */
public function store($id, $group, $data)
{
    $cache_id = $this->_getCacheId($id, $group);
    if (!$this->lockindex()) {
        return false;
    }
    $index = static::$_db->get($this->_hash . '-index');
    if (!\is_array($index)) {
        $index = array();
    }
    $tmparr = new \stdClass();
    $tmparr->name = $cache_id;
    $tmparr->size = \strlen($data);
    $index[] = $tmparr;
    static::$_db->set($this->_hash . '-index', $index, 0);
    $this->unlockindex();
    static::$_db->set($cache_id, $data, $this->_lifetime);
    return true;
}