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

getMulti can return non-unique keys #13

Closed
andreiz opened this issue Apr 1, 2012 · 4 comments
Closed

getMulti can return non-unique keys #13

andreiz opened this issue Apr 1, 2012 · 4 comments

Comments

@andreiz
Copy link
Member

andreiz commented Apr 1, 2012

Description:

When the binary protocol is enabled and when passing the 3rd
parameter, Memcached::GET_PRESERVE_ORDER, to getMulti(), the
resulting array contains non-unique keys.

In other words, each key is represented twice in the result.
One is set to null and the other is set to the value of
whatever was stored in memcached.

getResultMessage() shows "SUCCESS".

I'm actually on php 5.3.8

Reproduce code:

$MC = new Memcached;
$MC->setOption(Memcached::OPT_BINARY_PROTOCOL, true); // Removing this
causes the code to work, but at the 'expense' of reverting to the ASCII
protocol
$MC->addServer('localhost', 11211);

$KeyList = Array (
'key1'
,'key2'
,'key3'
,'key4'
);

$Test = Array();
foreach ($KeyList as $k) {
$Test[$k] = 'stored value for '.$k;
}

// This block uses the *Multi() functions
$MC->setMulti($Test, 3600);

sleep(1);
$null = null;
$theList = $MC->getMulti($KeyList, $null, Memcached::GET_PRESERVE_ORDER);

var_dump($theList);

Expected result:

var_dump should shows:

array
'key1' => 'stored value for key1'
'key2' => 'stored value for key2'
'key3' => 'stored value for key3'
'key4' => 'stored value for key4'

Actual result:

var_dump shows:

array
'key1' => null
'key2' => null
'key3' => null
'key4' => null
'key1' => 'stored value for key1'
'key2' => 'stored value for key2'
'key3' => 'stored value for key3'
'key4' => 'stored value for key4'

@asuth
Copy link

asuth commented Nov 3, 2012

just hit this. Any timeline for fixing?

@frickenate
Copy link

Here's the original pecl bug report: https://bugs.php.net/bug.php?id=59990 .

Note that this is not exclusive to the use of GET_PRESERVE_ORDER, I came across this bug without using that option. For the time being, just disable the use of the binary protocol, and the bug disappears.

@mkoppanen
Copy link
Member

Has this been fixed?

@mkoppanen
Copy link
Member

Closing as no feedback in a while. Reopen if the issue persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants