/** * Actual query with caching results in local for current request * @inheritdoc */ protected function queryInternal($method, $fetchMode = null) { if ($method !== '') { $rawSql = $this->getRawSql(); $requestLocalCacheKey = implode('', [__CLASS__, $method, $fetchMode, $this->db->dsn, $this->db->username, preg_replace('/\\s+/', '', $rawSql)]); mb_convert_encoding($requestLocalCacheKey, 'UTF-8', 'UTF-8'); if (($result = static::$requestLocalCache->get($requestLocalCacheKey)) !== false) { Yii::info('Query result served from request local cache' . PHP_EOL . 'Query: ' . VarDumper::dumpAsString($rawSql) . PHP_EOL . 'Result: ' . VarDumper::dumpAsString($result), __METHOD__); return $result; } static::$requestLocalCache->set('rawSql', $rawSql); } $result = parent::queryInternal($method, $fetchMode); if ($method !== '') { static::$requestLocalCache->set($requestLocalCacheKey, $result); } return $result; }