Answer the question
In order to leave comments, you need to log in
How to know if a request is cached in Yii 1 (memcached)?
I connected memcache in the config, everything is configured and enabled on the machine (dll and the service itself is running)
How can I find out if requests are really cached?
Climbed into the framework, found such a thing CDbCommand 495 line
if(($result=$cache->get($cacheKey))!==false)
{
Yii::trace('Query result found in cache','system.db.CDbCommand');
return $result[0];
}
$result = Yii::app()->db->cache(600)->createCommand('SELECT COUNT(*) as count FROM wo_users')->queryRow();
Answer the question
In order to leave comments, you need to log in
you can check memcached statistics from the command line. here is a link .
1. Clear the cache.
2. See if the cache is empty - the cache must be empty
3. We cache ONLY one request.
4. Make this request
5. Check if the cache is empty - the cache must not be empty
The condition is set to check if there is data in the cache for such and such a key. If they are, then the data is taken from the cache. If they are not there, then you need to put them there and return the data. Before using the cache, you need to describe it as a module in the config. To check if the cache itself works, you can check it directly without caching requests, but by caching just data:
$dataCacheKey = 'data_key';
if($data = Yii::app()->cache->get($dataCacheKey)){
echo 'Data cached';
}else{
$data = 'asd';
Yii::app()->cache->add($dataCacheKey, $data);
}
return $data;
// навскидку как-то так
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question