1
Quand je veux utiliser yii\caching\DbCache
dans mon code yii2, je reçois:Comment créer une table en utilisant ('cache') dans yii2 dbcache?
Error: Table "cache" does not exist.
Comment puis-je créer ce tableau?
config/web.php:
'cache' => [
'class' => 'yii\caching\DbCache',
],
code du contrôleur:
$cache = Yii::$app->cache;
$duration = 30;
if($currency == 'USD')
{
// try retrieving $data from cache
$data = $cache->get('getCurrencyUSD');
if($data === false)
{
$url = 'wsdl file address ...';
$client = new SoapClient($url);
$data = $client->getCurrency('USD');
$cache->set('getCurrencyUSD', $data, $duration);
return $data;
}
}
document pour le cache utilisation de DB http : //www.yiiframewo rk.com/doc-2.0/yii-caching-dbcache.html#$cacheTable-detail – dungphanxuan