If you create a cache table as specified by the yii\caching\DbCache::$cacheTable docs, and configure your cache component to use yii\caching\DbCache, you will get SQL errors about missing dateCreated, dateUpdated and uid columns.
That happens because craft\db\Command::upsert() and insert() (which yii\caching\DbCache uses) assume that these columns exist, as they do for the vast majority of Craft鈥檚 database tables.
These errors can be worked around by adding those three columns to the cache table, in addition to the columns Yii requires, however they serve no purpose and actually may slow database caching down, so that鈥檚 not a great solution.
Instead we should provide our own DbCache class, which extends Yii鈥檚 and overrides its setValue() and addValue() methods, making them compatible with craft\db\Command by passing false to the $includeAuditColumns argument on upsert() and insert().
This is now resolved for the next release (3.4.14).
Going forward you will be able to set the cache component to a new craft\cache\DbCache class, which is fully compatible with craft\db\Command.
// -- config/app.php --
return [
'components' => [
'cache' => craft\cache\DbCache::class,
],
];
Also added a new setup/db-cache-table command, which can be run to quickly create the cache table as specified by yii\cachingDbCache::$cacheTable.
Craft 3.4.14 is out with this change.
Most helpful comment
This is now resolved for the next release (3.4.14).
Going forward you will be able to set the
cachecomponent to a newcraft\cache\DbCacheclass, which is fully compatible withcraft\db\Command.Also added a new
setup/db-cache-tablecommand, which can be run to quickly create thecachetable as specified by yii\cachingDbCache::$cacheTable.