Skip to content

[BUG] Phalcon 2.1.b: Libmemcached::queryKeys($keyPrefix) - "$keyPrefix" is ignored, all keys are returned. #11024

Closed
@temuri416

Description

@temuri416

Hi,

The code:

class Memc extends Phalcon\Cache\Backend\Libmemcached
{
    function getConn() {
        return $this->_memcache;
    }
}

 $frontCache = new \Phalcon\Cache\Frontend\Data(array(
    "lifetime" => 172800
 ));
 $cache = new Memc($frontCache, array(
     "servers" => array(
         array('host' => 'localhost',
               'port' => 11211,
               'weight' => 1),
     ),
     'statsKey' => '_PHCM',
));

$cache->save('prefix1-myKey', ['a', 'b']);
$cache->save('prefix2-myKey', ['x', 'z']);
$prefix1Keys = $cache->queryKeys('prefix1');
$_PHCM = $cache->getConn()->get('_PHCM');

I expect $prefix1Keys to only contain prefix1-myKey, however it also includes prefix2-myKey.

$_PHCM correctly lists both keys as array keys and TTL as values.

Zephir source of queryKeys() is dead simple and my $_PHCM is equivalent of keys below:

let keys = memcache->get(specialKey);
if typeof keys == "array" {
    let keys = array_keys(keys);
    for key in keys {
        if prefix && !starts_with(key, prefix) {
            unset keys[key];
        }
    }
}

No idea what may be failing there...

Thanks!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions