diff --git a/ext/cache/backend/xcache.c b/ext/cache/backend/xcache.c index 34f6603db34..928eef91443 100644 --- a/ext/cache/backend/xcache.c +++ b/ext/cache/backend/xcache.c @@ -275,13 +275,11 @@ PHP_METHOD(Phalcon_Cache_Backend_Xcache, save){ array_init(keys); } - if (!zend_is_true(keys)) { - phalcon_array_update_zval(&keys, last_key, &ttl, PH_COPY | PH_SEPARATE); - - PHALCON_INIT_VAR(zero); - ZVAL_LONG(zero, 0); - phalcon_call_func_p3_noret("xcache_set", special_key, keys, zero); - } + phalcon_array_update_zval(&keys, last_key, &ttl, PH_COPY | PH_SEPARATE); + + PHALCON_INIT_VAR(zero); + ZVAL_LONG(zero, 0); + phalcon_call_func_p3_noret("xcache_set", special_key, keys, zero); } PHALCON_MM_RESTORE(); @@ -322,7 +320,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Xcache, delete){ if (Z_TYPE_P(keys) == IS_ARRAY) { PHALCON_INIT_VAR(zero); ZVAL_LONG(zero, 0); - phalcon_array_unset(&keys, special_key, PH_SEPARATE); + phalcon_array_unset(&keys, prefixed_key, PH_SEPARATE); phalcon_call_func_p3_noret("xcache_set", special_key, keys, zero); } diff --git a/unit-tests/CacheTest.php b/unit-tests/CacheTest.php index 2a33be4d89c..3f67ec71986 100644 --- a/unit-tests/CacheTest.php +++ b/unit-tests/CacheTest.php @@ -682,4 +682,32 @@ public function testDataXcache() $this->assertTrue($cache->delete('test-data')); } + + public function testXcacheQueryKeys() + { + $ready = $this->_prepareXcache(); + if (!$ready) { + return false; + } + + $frontCache = new Phalcon\Cache\Frontend\None(array( + 'lifetime' => 2 + )); + + $cache = new Phalcon\Cache\Backend\Xcache($frontCache); + + + $cache->delete('test-output'); + $cache->delete('test-data'); + + $cache->save('test-one', 'one'); + $cache->save('test-two', 'two'); + + //Query keys + $keys = $cache->queryKeys(); + $this->assertEquals($keys, array( + 0 => 'test-one', + 1 => 'test-two', + )); + } }