Why would you *want* a wraparound when incrementing?<br>Quite the opposite for me, I do not want it to wrap around, because then I would require additional code to check that. Right now, very simply... if my increment fails, I reset all the data that is associated with that key, and start again.
<br><br>Although, it is possible that treat a '0' returned as a wrap failure in your scenario, it is easier for me to treat the wrap error the same as if the key had expired, or the service had been restarted, causing me to replenish the data that appears to be missing.
<br><br><div><span class="gmail_quote">On 8/17/07, <b class="gmail_sendername">Evan Miller</b> <<a href="mailto:emiller@imvu.com">emiller@imvu.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Currently Memcached gives an error when incrementing large counters:<br><br>set foobar 0 0 10<br>2147483647<br>STORED<br>incr foobar 1<br>2147483648<br>incr foobar 1<br>CLIENT_ERROR cannot increment or decrement non-numeric value
<br><br>I believe this is a bug. Attached is a patch to make counters wrap<br>around the 2**32 mark, similar to counters in routers. New behavior:<br><br>set foobar 0 0 10<br>4294967294<br>STORED<br>incr foobar 1<br>4294967295
<br>incr foobar 1<br>0<br><br>A CLIENT_ERROR will continue to be returned if a value above 2**32 is<br>incremented, but the "incr" command will never push the value over that<br>mark.<br><br>A future version of Memcached should probably use a 64-bit counter
<br>instead, but the 32-bit limit is in line with the existing docs. ("The<br>data for the item is treated as decimal representation of a 32-bit<br>unsigned integer.")<br><br>The patch also adds "const" keywords to arguments of do_add_delta and
<br>mt_add_delta, to be consistent with the header file.<br><br>Documentation and tests have been updated.<br><br>Evan Miller<br>IMVU, Inc.<br><br></blockquote></div><br><br clear="all"><br>-- <br>"Be excellent to each other"