1
當我想在我的yii2代碼中使用yii\caching\DbCache
,我得到:如何在yii2 dbcache中使用('cache')創建表?
Error: Table "cache" does not exist.
我如何創建該表?
配置/ web.php:
'cache' => [
'class' => 'yii\caching\DbCache',
],
控制器代碼:
$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;
}
}
文檔使用DB HTTP緩存://www.yiiframewo rk.com/doc-2.0/yii-caching-dbcache.html#$cacheTable-detail – dungphanxuan