Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: xcache only save the first key #1406

Merged
merged 5 commits into from
Oct 22, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions ext/cache/backend/xcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}

Expand Down
28 changes: 28 additions & 0 deletions unit-tests/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
));
}
}