It seems that data expires as expected with Memcached, but the keys themselves never expire. Why are the keys sticking around after the value has nulled? When I run this code:
$frontCache = new Phalcon\Cache\Frontend\Data(array(
"lifetime" => 30
));
//Create the Cache setting memcached connection options
$cache = new Phalcon\Cache\Backend\Memcache($frontCache, array(
'host' => 'localhost',
'port' => 11211,
'persistent' => false
));
//Cache arbitrary data
$myNewRandomKey = generateNewRandomKey();
$cache->save($myNewRandomKey, array(1, 2, 3, 4, 5));
Taken from http://docs.phalconphp.com/en/latest/api/Phalcon_Cache_Backend_Memcache.html
I can succesfully save the array under the key $myNewRandomKey. I then run this code after the 30 second timeout has expired:
$keys = $cache->queryKeys();
print_r($keys);
And see that the key STILL EXISTS, though the data is NULL, where it was populated before the timeout expired. This seems only half-right to me. The key should have cleared too.
However, If I run $cache->delete($myNewRandomKey); the key will completely erase. Inconsistent!
Bottom line: If the keys don't expire or memcached is buggy, then will they grow and grow over time until it causes a different type of headache - a sysadmin headache?
Stats:
Windows 7 64bit
Apache 2.4.4
PHP 5.4.12
Memcached 1.4.4-14-g9c66c0
Memcache Apache extension version 2.2.7-5.4-VC9-x64 from http://www.anindya.com/category/windows/
Client: Phalcon PHP
Those are the versions, but I'm hoping that's irrelevant to the problem and that my expectations are wrong.
Cheers to all SO'ers!
SL