Answer the question
In order to leave comments, you need to log in
Doesn't save in yii2 cache?
config:
'cache' => [
'class' => 'yii\caching\FileCache',]
if(Yii::$app-> cache-> exists('name'))
$t = Yii::$app-> cache-> get('name');
else
$t = Yii::$app->cache->set('name', '1234566788');
Answer the question
In order to leave comments, you need to log in
bool(false).
There is a suspicion that I have some settings for filecache missing. Can you suggest where to dig?
You have a strange example, it should not work, try like this:
$cache = \Yii::$app->cache;
$t = $cache->get('name');
if ($t === false) {
$t = 'some string';
$cache->set('name', $t);
}
var_dump($t)
$t
, you will have a boolean, where do you get data from the cache? You, if there is a cache, take it, and if not, you set it, but after setting the cache, you need to drive it into the $t variable. To see something.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question