APC 密钥超时是否在单个请求中起作用?
这是我的 PHPUnit 测试函数代码的主体:
$key = 'test:foobar';
$valueIn = 'this is a test string';
$success = apc_store( $key, $valueIn, 1 ); // 1 second expire time
$this->assertTrue( $success );
$valueOut = apc_fetch( $key );
$this->assertEquals( $valueIn, $valueOut );
sleep(2); // wait 2 seconds
$valueOut = apc_fetch( $key );
$this->assertEquals( false, $valueOut ); // <<< This assert fails!
我的问题是,为什么最后一次获取时 $valueOut == $valueIn ?密钥不应该过期并返回 false 吗?我也尝试过等待10秒,但没有成功。
我使用 apc.php 来检查缓存,密钥就在其中,并有 1 秒过期时间。当我检查该键时,该值为 false,这符合预期。我正在使用 APC 3.1.7
Here's the body of my PHPUnit test function code:
$key = 'test:foobar';
$valueIn = 'this is a test string';
$success = apc_store( $key, $valueIn, 1 ); // 1 second expire time
$this->assertTrue( $success );
$valueOut = apc_fetch( $key );
$this->assertEquals( $valueIn, $valueOut );
sleep(2); // wait 2 seconds
$valueOut = apc_fetch( $key );
$this->assertEquals( false, $valueOut ); // <<< This assert fails!
My question is, why is $valueOut == $valueIn on the last fetch? Shouldn't the key expire and return false? I've also tried waiting 10 seconds and it doesn't work.
I've used apc.php to examine the cache, and the key is in there with a 1-second expire. When I examine the key, the value is false, which is as expected. I'm using APC 3.1.7
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,变量不会在单个请求内过期。
apc_store
的 PHP 文档具有以下内容说说ttl
(生存时间)参数(强调我的):No, variables are not expired within a single request.
The PHP documentation for
apc_store
has the following to say about thettl
(time to live) argument (emphasis mine):