yii\db\Command::cache PHP Method

cache() public method

Enables query cache for this command.
public cache ( integer $duration = null, yii\caching\Dependency $dependency = null )
$duration integer the number of seconds that query result of this command can remain valid in the cache. If this is not set, the value of [[Connection::queryCacheDuration]] will be used instead. Use 0 to indicate that the cached data will never expire.
$dependency yii\caching\Dependency the cache dependency associated with the cached query result.
    public function cache($duration = null, $dependency = null)
    {
        $this->queryCacheDuration = $duration === null ? $this->db->queryCacheDuration : $duration;
        $this->queryCacheDependency = $dependency;
        return $this;
    }