Back to ViewController class

Method store

public bool
store
(mixed $data, mixed $id, mixed $group = null, mixed $wrkarounds = true)
Store data to cache by ID and group
Parameters
  • mixed $data The data to store
  • string $id The cache data ID
  • string $group The cache data group
  • bool $wrkarounds True to use wrkarounds
Returns
  • bool True if cache stored
Since
  • 4.0.0

Method store - Source code

/**
 * Store data to cache by ID and group
 *
 * @param   mixed    $data        The data to store
 * @param   string   $id          The cache data ID
 * @param   string   $group       The cache data group
 * @param   boolean  $wrkarounds  True to use wrkarounds
 *
 * @return  boolean  True if cache stored
 *
 * @since   4.0.0
 */
public function store($data, $id, $group = null, $wrkarounds = true)
{
    $locktest = $this->cache->lock($id, $group);
    if ($locktest->locked === false && $locktest->locklooped === true) {
        // We can not store data because another process is in the middle of saving
        return false;
    }
    $result = $this->cache->store(serialize($data), $id, $group);
    if ($locktest->locked === true) {
        $this->cache->unlock($id, $group);
    }
    return $result;
}