以下示例中apc_store();
和apc_fetch();
的用法是什么?
function getData($uid){
$cached = apc_fetch($uid);
return $cached?$cached:"Start";
}
function setData($uid,$step){
apc_store($uid,$step,60*60*12);
}
我想存储字符串,然后再使用它。我无法理解PHP中这两个函数的主要和一般解释。
答案 0 :(得分:0)
第一个方法getData($uid)
只是从缓存中返回$ uid的值,如果键$ uid没有变量,那么它将返回一个字符串" Start"。所以只需从缓存中返回$ uid的值。
第二种方法setData($uid,$step)
将缓存中的变量定义为$ uid,将值存储为$ step, ttl 60 * 60 * 12.
TTL是定义缓存变量 $ uid。的生命周期的时间 (生存时间;将var存储在缓存中ttl秒。)
apc_store($key,$val,$time_in_seconds);
//This method stores variable in alternative PHP cache and this is used for performance.
有关详细信息,请参阅:
另请查看apc