luya\traits\CacheableTrait::setHasCache PHP Method

setHasCache() public method

Store cache data for a specific key if caching is enabled in this application.
public setHasCache ( string | array $key, mixed $value, yii\caching\Dependency | array $dependency = null, $cacheExpiration = null ) : boolean
$key string | array The identifier key or a array to store complex keys
$value mixed The value to store in the cache component.
$dependency yii\caching\Dependency | array Dependency of the cached item. If the dependency changes, the corresponding value in the cache will be invalidated when it is fetched via get(). This parameter is ignored if $serializer is false. You can also define an array with defintion which will generate the Object instead of object is provided.
return boolean Whether set has been success or not
    public function setHasCache($key, $value, $dependency = null, $cacheExpiration = null)
    {
        if ($this->isCachable()) {
            if (is_array($dependency)) {
                $dependency = Yii::createObject($dependency);
            }
            return Yii::$app->cache->set($key, $value, is_null($cacheExpiration) ? $this->cacheExpiration : $cacheExpiration, $dependency);
        }
        return false;
    }