cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[2.0.0][cache] redis adapter bug

Open eclipse88 opened this issue 11 years ago • 4 comments


 $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

eclipse88 avatar Apr 21 '15 05:04 eclipse88

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.

Green-Cat avatar Apr 21 '15 08:04 Green-Cat

Deleting is working, was a problem with my connection details but i have problems with other thinks:

  1. my cache is deleting almost every request and i don't know why.
  2. i don't understand if options["prefix"] is same think with options["statsKey"] in redis.zep
  3. i tink this "_PHCR" is hardcoded here redis.zep (line 277)

eclipse88 avatar Apr 22 '15 10:04 eclipse88

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

eclipse88 avatar Apr 22 '15 10:04 eclipse88

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.

ghost avatar Apr 29 '15 15:04 ghost