[2.0.0][cache] redis adapter bug
$frontCache = new \Phalcon\Cache\Frontend\Data(array(
"lifetime" => 172800
));
$cache = new Phalcon\Cache\Backend\Redis($frontCache, array(
'host' => 'localhost',
'port' => 6379,
'auth' => 'foobared',
'persistent' => false
));
$cache->save('my-data', array(1, 2, 3, 4, 5));
//delete cache not working
$cache->delete('my-data');
delete not working
Could you please run var_dump($cache->delete('my_data')); ? If it returns false it would mean that there is a redis connection or configuration issue.
Deleting is working, was a problem with my connection details but i have problems with other thinks:
- my cache is deleting almost every request and i don't know why.
- i don't understand if options["prefix"] is same think with options["statsKey"] in redis.zep
- i tink this "_PHCR" is hardcoded here redis.zep (line 277)
I see if i have a list of keys something like this: Ex.: _PHCRasd_123 _PHCRasd_234 _PHCRasd_567 _PHCRqwe_123 _PHCRqwe_234
And if i do this:
$keys = $cache->queryKeys('asd');
var_dump($keys);die;//this will return all keys not just the keys that contains "asd" pattern
foreach($keys as $k){
$cache->delete($k);
}
And this is the reason why my cache is deleting. In 1.3.4(incubator version) queryKeys($key) returning just keys that matching the pattern $key
I think I have a fix for this it looks like the function in redis.zep is comparing the key rather than the value and this never removes the unnecessary items.