yii\caching\Cache::multiSet PHP Method

multiSet() public method

If the cache already contains such a key, the existing value and expiration time will be replaced with the new ones, respectively.
Since: 2.0.7
public multiSet ( array $items, integer $duration, yii\caching\Dependency $dependency = null ) : array
$items array the items to be cached, as key-value pairs.
$duration integer default number of seconds in which the cached values will expire. 0 means never expire.
$dependency yii\caching\Dependency dependency of the cached items. If the dependency changes, the corresponding values in the cache will be invalidated when it is fetched via [[get()]]. This parameter is ignored if [[serializer]] is false.
return array array of failed keys
    public function multiSet($items, $duration = 0, $dependency = null)
    {
        if ($dependency !== null && $this->serializer !== false) {
            $dependency->evaluateDependency($this);
        }
        $data = [];
        foreach ($items as $key => $value) {
            if ($this->serializer === null) {
                $value = serialize([$value, $dependency]);
            } elseif ($this->serializer !== false) {
                $value = call_user_func($this->serializer[0], [$value, $dependency]);
            }
            $key = $this->buildKey($key);
            $data[$key] = $value;
        }
        return $this->setValues($data, $duration);
    }