I have few question where I am confused about the server side cache in PHP. I am using Yii2 to set MemCache. And my question are:-
1.How can I get expire time of cache variable with id?
\Yii::$app->cache->set('cacheId',$counter,$expireTime); //set cache with id cacheId
2.If I set same cache id/ overwrite cache id without $expireTime. It will take default expire time or from before?
\Yii::$app->cache->set('cacheId',\Yii::$app->cache->get(cacheId)+1); //overwrite cachewith id cacheId.
Code looks are in Yii2 but my question is related to server side cache mechanism in PHP.
Thanks You.
Question 1.
Yii2 does not offer a way to retrieve expiration time, see API Documentation. MemCache specifically also does not support this if you check the PHP Reference, so if this information is crucial for your scenario, you have to store it yourself or use a cache implementation which supports it.
Question 2.
Yes, if you overwrite a cached item with set
, a completely new expiration time will be applied, so if none is given, the default will be used.