sanchezzzhak / kak-clickhouse

Yii2 ext. ClickHouse
69 stars 43 forks source link

why disable query cache? #55

Closed qihuajun closed 2 years ago

qihuajun commented 2 years ago

When creating query command, this component's code disable cache.

Here is the code in \yii\db\Query:

$command = $db->createCommand($sql, $params);
 $this->setCommandCache($command);

the code in \kak\clickhouse\Query:

$this->_command = $db->createCommand($sql, $params);

Are there any problems about this component's supporting for query cache?

sanchezzzhak commented 2 years ago

this method was added much later than the implementation of the clickhouse component

the setCommandCache method was needed only for this case

$query = new Query;
$query->cache(10);
$command = $query->createCommand();
var_dump($command->queryCacheDuration);  // 10

Now, it should work.


Working with the cache is the same as in a standard component


// QueryBuilder
$dd = new kak\clickhouse\Query();
// ...
$dd->cache(5);
$dd->all();

// DAO
$dd = $db->createCommand($sql);
$dd->cache(5);
// ...
$dd->queryAll();
qihuajun commented 2 years ago

@sanchezzzhak Thanks!