PHP APCu setting deletion time so keys automatically delete themselves
one text
I'm working with APCu in PHP.
I'm setting a key and its value, setting the expiration, but after the expiration it's not deleting itself. I guess this is because checking if something is expired and deleting it when its expired are two different things and I get that.
I see in var_dump there is another value called "deletion_time". How do I set the deletion so that my keys delete after 10 seconds of being stored?
<?php
// First I store the key with the expiration time of 10 seconds
$ip = 1.0.0.1;
$expires = 10;
$value = array("requests" => 1);
apcu_store($ip, $value, $expires);
// But then on the next request when I check the key I get the following, and the key isn't deleted
sleep(11);
var_dump(apcu_key_info($ip));
//{ ["hits"]=> int(1) ["access_time"]=> int(5629781) ["mtime"]=> int(5629765) ["creation_time"]=> int(5629765) ["deletion_time"]=> int(0) ["ttl"]=> int(10) ["refs"]=> int(0) }
?>
Source