yii\caching\DbDependency::generateDependencyData PHP Method

generateDependencyData() protected method

This method returns the value of the global state.
protected generateDependencyData ( Cache $cache ) : mixed
$cache Cache the cache component that is currently evaluating this dependency
return mixed the data needed to determine if dependency has been changed.
    protected function generateDependencyData($cache)
    {
        $db = Instance::ensure($this->db, Connection::className());
        if ($this->sql === null) {
            throw new InvalidConfigException('DbDependency::sql must be set.');
        }
        if ($db->enableQueryCache) {
            // temporarily disable and re-enable query caching
            $db->enableQueryCache = false;
            $result = $db->createCommand($this->sql, $this->params)->queryOne();
            $db->enableQueryCache = true;
        } else {
            $result = $db->createCommand($this->sql, $this->params)->queryOne();
        }
        return $result;
    }