core/traits/CacheableTrait.php
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;
    }
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;
    }
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 ; }
Store cache data for a specific key if caching is enabled in this application.

@param string|array $key The identifier key or a array to store complex keys
@param mixed $value The value to store in the cache component.
@param \yii\caching\Dependency|array $dependency 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.
@param $cacheExpiration integer The time in seconds before the cache data expires, 0 means never expire.
@return boolean Whether set has been success or not
Store cache data for a specific key if caching is enabled in this application .