通过指定TTL,项目应该在缓存中过期。但它不起作用。这非常非常简单。TTL设置为1秒。我是不是搞错了?
我的版本;
PHP 7.0.12-1+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.12-1+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies我的脚本;
cat apcu.php
<?php
$key="KEY";
function xxx($key) {
if (apcu_exists($key)) {
print ("In Store\n");
$value = apcu_fetch($key);
var_dump($value);
} else {
$value = "Hello Big Daddy";
apcu_add($key, $value, 1);
print ("Not in store, adding\n");
}
}
xxx($key);
sleep(2);
xxx($key);
sleep(3);
xxx($key);输出;
php apcu.php
Not in store, adding
In Store
string(15) "Hello Big Daddy"
In Store
string(15) "Hello Big Daddy"我不认为项目应该在第二次调用时出现在缓存中。
但是,即使有人说它应该,那么它肯定不应该在第三次调用时出现在缓存中。
发布于 2017-08-02 06:41:22
当apc.use_request_time设置为true (默认值)时,就会发生这种情况-- SAPI请求开始时间用于TTL计算,而不是调用每个函数的时间。
https://stackoverflow.com/questions/40156486
复制相似问题