yii\db\Connection::noCache PHP Method

noCache() public method

Queries performed within the callable will not use query cache at all. For example, php $db->cache(function (Connection $db) { ... queries that use query cache ... return $db->noCache(function (Connection $db) { this query will not use query cache return $db->createCommand('SELECT * FROM customer WHERE id=1')->queryOne(); }); });
See also: enableQueryCache
See also: queryCache
See also: cache()
public noCache ( callable $callable ) : mixed
$callable callable a PHP callable that contains DB queries which should not use query cache. The signature of the callable is `function (Connection $db)`.
return mixed the return result of the callable
    public function noCache(callable $callable)
    {
        $this->_queryCacheInfo[] = false;
        try {
            $result = call_user_func($callable, $this);
            array_pop($this->_queryCacheInfo);
            return $result;
        } catch (\Exception $e) {
            array_pop($this->_queryCacheInfo);
            throw $e;
        }
    }