Hi我在使用APCu缓存系统"APCu_cas"的功能时遇到问题http://php.net/manual/en/function.apc-cas.php我有一个存储在缓存密钥中的数组,当我试图用一个新数组更新密钥的值时,我得到了这个错误:
Warning: apcu_cas() expects parameter 2 to be long, array on line apcu_cas($cache_key, $data, $value);
我的代码:
$value = array(
"first_name" => "John",
"last_name" => "Doe"
);
$cache_key = "my_cached_key";
$result = false;
$data = apcu_fetch($cache_key, $result);
if(!$result){
//is not cached, so i add it
apcu_add($cache_key, $value, 600);//10min
}else{
//data is cached, i update it
apcu_cas($cache_key, $data, $value);
}
apcu_cas($cache_key, $data, $value);
这是错误。第二个参数($data)是一个数组,而不是整数。请参阅文档:bool apc_cas ( string $key , int $old , int $new )