We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon\Cache\Backend\Memcache delete() not working with prefix

Here is my configure:

    $cache = new Phalcon\Cache\Backend\Memcache($frontCache, array(
        "prefix" => "cache",
        "host" => "localhost",
        "port" => "11211"
    ));

Here is the code that function delete() not working:

    $keys = $this->cache->queryKeys();
    foreach($keys as $key) {
        $this->cache->delete($key)
    }

If prefix is empty "prefix" => "" it works properly

I have the same problem. You can use $this->cache->flush(), but it only deletes all keys with your current prefix. I have situation when i have cache with multiple clients and i want to invalidate all cache. So the only workaround i found was to init cache without prefix and then execute you second code snippet.

$cache = new Phalcon\Cache\Backend\Memcache($frontCache, array( "host" => "localhost", "port" => "11211" ));

$keys = $this->cache->queryKeys(); foreach($keys as $key) { $this->cache->delete($key) }