APC user cache entries do not expire

I see 5 output every time I run this code:

<?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 I clear the cached entry from the cache and return false in apc_fetch ()? User_ttl is 2 for APC. I'm still trying to figure out what user_ttl does (the documentation is pretty cryptic).

+4
source share
1 answer

From the manual:

Time to live ; save var in ttl seconds cache. After ttl , the saved variable will be deleted from the cache (in the next request ). If ttl is not specified (or if ttl is 0), the value will remain until it is manually removed from the cache or otherwise does not exist in the cache (flush, reboot, etc.).

So, he says that the item is removed from the cache after TTL at the next request. This way, the item is not removed from the cache until the next request, so you keep getting 5.

+4
source

All Articles