roc230 / spymemcached

Automatically exported from code.google.com/p/spymemcached
0 stars 0 forks source link

Atomic addOrIncr #91

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version 2.2 on Linux.

It would be nice to have atomic addOrIncr operations, like that in the
Whalin client. 

At first I thought the incr(java.lang.String key, int by, long def) method
does that, but testing shows that the def value is not used to initialize
the counter on the server at all.

Original issue reported on code.google.com by weika...@gmail.com on 2 Oct 2009 at 12:03

GoogleCodeExporter commented 9 years ago
I verify this behavior on text and binary protocols (over ipv4 and ipv6 if it
matters).  I'm not sure how you're observing it's not working, but if you find a
variation of this test that shows what you're seeing, I'd love to see it:

http://github.com/dustin/java-memcached-client/blob/master/src/test/java/net/spy
/memcached/ProtocolBaseCase.java#L421

Original comment by dsalli...@gmail.com on 2 Oct 2009 at 5:12

GoogleCodeExporter commented 9 years ago
Yes, the incr() method itself works fine. I was having problem with getting and
setting the *current* value of a counter, but have since then made it work by 
fixing
a transcoding issue.

It would be nice to provide getCounter() and storeCounter() methods like those 
in the
Whalin client.

Original comment by weika...@gmail.com on 2 Oct 2009 at 7:38

GoogleCodeExporter commented 9 years ago
The only issue with this is that the API is already really messy.

getCounter() is the same as incr(0) and setCounter is really the same as calling
set() with String.valueOf(counterValue).

I'm hoping to, at some point, break the API and move some stuff out, but as of 
now, I
want to avoid adding anything to the API that can be done a different way.

Original comment by dsalli...@gmail.com on 7 Oct 2009 at 10:55

GoogleCodeExporter commented 9 years ago
This incr(0) should be documented with the blink tag somewhere.  :)

Original comment by nafe...@gmail.com on 7 Nov 2011 at 10:02