嗨,我在使用 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);
}