Couchbase 2.2.0 incompatibility with php Memcached library

Hi,

I seem to have found an incompatibility in the latest version of Couchbase I just installed (should be 2.2.0) and the php Memcached library (and I have PHP 5.3), and no one seems to have mentioned this anywhere on the net, so I just want to ask here to see if someone can confirm.

I was attempting to use the php Memcached library’s increment() and decrement() calls. They simply didn’t work with my Couchbase server. They returned nothing and did not increment or decrement the value in the specified key.

I then installed the php couchbase pecl library. I ran a test script testing increment() and decrement() using that and they worked perfectly.
(I don’t necessarily have an issue with using this library, it’s just new to me and I worry a little bit about things like performance, since it seem to does some magic/smart things on connect)

Is this an undocumented incompatibility with Couchbase server 2.2.0 and php Memcached’s increment() and decrement()?

Thanks.

Hello,

Do you mind sharing a code snipplet?
Do you see any error in the log?

Asking because it is supposed to work…

Regards
Tug
@tgrall

It’s been a while so I don’t know what I did wrong, but just tested it and it does work actually. Sorry and thanks!

Hi tgrall,

Actually I tested it some more and I know what was wrong now.
The php memcached increment fails if you try to use the initial_value parameter (3rd parameter).
See this doc:
http://www.php.net/manual/en/memcached.increment.php

If I only use the “key” param and the “offset” param, increment works correctly.
If I pass anything at all for “initial_value”, couchbase fails to handle it properly, and rather than ignoring it, the call itself fails out.

Hope this helps, not a high priority fix, I understand, but useful info regardless.

Just to demonstrate it really clearly, here is some code snippet.
Test code:

$mc = new Memcached(); $mc->addServers(array(array('127.0.0.1','11211')));

$mc->set(‘mytestkey’, 1);
error_log($mc->get(‘mytestkey’));
$res = $mc->increment(‘mytestkey’, 1);
error_log(‘inc result:’);
var_dump($res);
error_log($mc->get(‘mytestkey’));
$mc->decrement(‘mytestkey’);
error_log($mc->get(‘mytestkey’));

$res = $mc->increment(‘mytestkey’, 1, 1);
error_log(‘inc result:’);
var_dump($res);
error_log($mc->get(‘mytestkey’));
$mc->decrement(‘mytestkey’);
error_log($mc->get(‘mytestkey’));

Output:

1
inc result:
int(2)
2
1
inc result:
bool(false)
1
0