简体   繁体   English

APC用户缓存条目未过期

[英]APC user cache entries not expiring

I see 5 output each time when I run this code: 运行此代码时,每次都会看到5条输出:

<?php
$v = 5;
apc_store('vwxyz',$v,3);
$before = apc_fetch('vwxyz');
sleep(5);
$after = apc_fetch('vwxyz'); //should be false
echo $before;
echo "<br>";
echo $after;
$later = apc_fetch('vwxyz'); //OK this should definitely be false
echo "<br>";
echo $later;

Shouldn't the cached entry be cleared from the cache and return false to apc_fetch()? 难道不应该从高速缓存中清除高速缓存的条目并将其返回false到apc_fetch()吗? The user_ttl setting is 2 for APC. APC的user_ttl设置为2。 I'm still trying to figure out what user_ttl does (the documentation is quite cryptic). 我仍在尝试找出user_ttl的功能(文档非常神秘)。

From the manual : 手册

Time To Live ; 生存时间 ; store var in the cache for ttl seconds. var在缓存中存储ttl秒。 After the ttl has passed, the stored variable will be expunged from the cache (on the next request ). 经过ttl之后,存储的变量将从缓存中删除( 在下一个请求时 )。 If no ttl is supplied (or if the ttl is 0), the value will persist until it is removed from the cache manually, or otherwise fails to exist in the cache (clear, restart, etc.). 如果未提供任何ttl (或ttl为0),则该值将一直保留,直到手动将其从缓存中删除为止,否则该值将在缓存中不存在(清除,重新启动等)。

So it says that the item gets removed from the cache after the TTL on the next request . 因此,它表示在下一个请求的TTL 之后 ,该项目已从缓存中删除。 So the item isn't removed from cache until your next request which is why you keep getting 5. 因此,直到您的下一个请求,该项目才会从缓存中删除,这就是为什么您会不断获得5。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM