I'm using in my project many counters by memcached:
$data = $mc->set('sasa', 100);
$data = $mc->get('sasa');
var_dump($data);
$res = $mc->add('sasa', 100);
var_dump($res);
result is
int(100)
bool(false)
int(100)
If I use memcached native protocol:
get sasa
VALUE sasa 1 3
100
END
add sasa 0 0 1
1
NOT_STORE
get sasa
VALUE sasa 1 3
100
END
ADD command is not work. https://github.com/memcached/memcached/blob/master/doc/protocol.txt#L132
Do You know, how to use ADD command in the memcached?
It may be that the usage of memory has reach the limit. Check it please, if yes, change the limit value in your config file.
I think you would like to increment a counter. You can do this with the incr protocoll level or the Memcache::increment commands.
The behavior you showed in your example is what should be expected. The ADD command will only add a key if it does not already exist.