Skip to content

Commit fcac25c

Browse files
author
mengli
committed
Change the implementation of addOrIncr and addOrDecr to make it compatible with previous version.
1 parent aaedea0 commit fcac25c

24 files changed

+69
-69
lines changed

src/main/com/schooner/MemCached/AbstractTransCoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* written size for memcached set operation.
3838
*
3939
* @author Xingen Wang
40-
* @since 2.5.1
40+
* @since 2.5.0
4141
* @see TransCoder
4242
* @see ObjectTransCoder
4343
*/

src/main/com/schooner/MemCached/AscIIClient.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
* memcached server.
6060
*
6161
* @author Xingen Wang
62-
* @since 2.5.1
62+
* @since 2.5.0
6363
* @see BinaryClient
6464
*/
6565
public class AscIIClient extends MemCachedClient {
@@ -470,35 +470,35 @@ private boolean set(String cmdname, String key, Object value, Date expiry, Integ
470470
}
471471

472472
public long addOrIncr(String key) {
473-
return addOrIncr(key, 1, null);
473+
return addOrIncr(key, 0, null);
474474
}
475475

476476
public long addOrIncr(String key, long inc) {
477477
return addOrIncr(key, inc, null);
478478
}
479479

480480
public long addOrIncr(String key, long inc, Integer hashCode) {
481-
boolean ret = add(key, "0", hashCode);
481+
boolean ret = add(key, "" + inc, hashCode);
482482

483483
if (ret) {
484-
return 0;
484+
return inc;
485485
} else {
486486
return incrdecr("incr", key, inc, hashCode);
487487
}
488488
}
489489

490490
public long addOrDecr(String key) {
491-
return addOrDecr(key, 1, null);
491+
return addOrDecr(key, 0, null);
492492
}
493493

494494
public long addOrDecr(String key, long inc) {
495495
return addOrDecr(key, inc, null);
496496
}
497497

498498
public long addOrDecr(String key, long inc, Integer hashCode) {
499-
boolean ret = add(key, "0", hashCode);
499+
boolean ret = add(key, "" + inc, hashCode);
500500
if (ret) {
501-
return 0;
501+
return inc;
502502
} else {
503503
return incrdecr("decr", key, inc, hashCode);
504504
}

src/main/com/schooner/MemCached/AscIIUDPClient.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
* memcached server.
5454
*
5555
* @author Xingen Wang
56-
* @since 2.5.1
56+
* @since 2.5.0
5757
* @see BinaryClient
5858
*/
5959
public class AscIIUDPClient extends MemCachedClient {
@@ -312,35 +312,35 @@ public void setTransCoder(TransCoder transCoder) {
312312
}
313313

314314
public long addOrDecr(String key) {
315-
return addOrDecr(key, 1, null);
315+
return addOrDecr(key, 0, null);
316316
}
317317

318318
public long addOrDecr(String key, long inc) {
319319
return addOrDecr(key, inc, null);
320320
}
321321

322322
public long addOrDecr(String key, long inc, Integer hashCode) {
323-
boolean ret = add(key, "0", hashCode);
323+
boolean ret = add(key, "" + inc, hashCode);
324324
if (ret) {
325-
return 0;
325+
return inc;
326326
} else {
327327
return incrdecr("decr", key, inc, hashCode);
328328
}
329329
}
330330

331331
public long addOrIncr(String key) {
332-
return addOrIncr(key, 1, null);
332+
return addOrIncr(key, 0, null);
333333
}
334334

335335
public long addOrIncr(String key, long inc) {
336336
return addOrIncr(key, inc, null);
337337
}
338338

339339
public long addOrIncr(String key, long inc, Integer hashCode) {
340-
boolean ret = add(key, "0", hashCode);
340+
boolean ret = add(key, "" + inc, hashCode);
341341

342342
if (ret) {
343-
return 0;
343+
return inc;
344344
} else {
345345
return incrdecr("incr", key, inc, hashCode);
346346
}

src/main/com/schooner/MemCached/BinaryClient.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
* memcached server.
5858
*
5959
* @author Xingen Wang
60-
* @since 2.5.1
60+
* @since 2.5.0
6161
* @see AscIIClient
6262
*/
6363
public class BinaryClient extends MemCachedClient {
@@ -575,35 +575,35 @@ private boolean apPrepend(byte opcode, String key, Object value, Integer hashCod
575575
}
576576

577577
public long addOrIncr(String key) {
578-
return addOrIncr(key, 1, null);
578+
return addOrIncr(key, 0, null);
579579
}
580580

581581
public long addOrIncr(String key, long inc) {
582582
return addOrIncr(key, inc, null);
583583
}
584584

585585
public long addOrIncr(String key, long inc, Integer hashCode) {
586-
boolean ret = add(key, "0", hashCode);
586+
boolean ret = add(key, "" + inc, hashCode);
587587

588588
if (ret) {
589-
return 0;
589+
return inc;
590590
} else {
591591
return incrdecr(OPCODE_INCREMENT, key, inc, hashCode);
592592
}
593593
}
594594

595595
public long addOrDecr(String key) {
596-
return addOrDecr(key, 1, null);
596+
return addOrDecr(key, 0, null);
597597
}
598598

599599
public long addOrDecr(String key, long inc) {
600600
return addOrDecr(key, inc, null);
601601
}
602602

603603
public long addOrDecr(String key, long inc, Integer hashCode) {
604-
boolean ret = add(key, "0", hashCode);
604+
boolean ret = add(key, "" + inc, hashCode);
605605
if (ret) {
606-
return 0;
606+
return inc;
607607
} else {
608608
return incrdecr(OPCODE_DECREMENT, key, inc, hashCode);
609609
}

src/main/com/schooner/MemCached/ByteBufArrayInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* This class will only be used in the multi-get memcached operations.
3131
*
3232
* @author Xingen Wang
33-
* @since 2.5.1
33+
* @since 2.5.0
3434
* @see ByteBufArrayInputStream
3535
*/
3636
public final class ByteBufArrayInputStream extends InputStream implements LineInputStream {

src/main/com/schooner/MemCached/MemcachedItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* MemcachedItem is used to hold casUnique and related memcached value.
3333
*
3434
* @author Xingen Wang
35-
* @since 2.5.1
35+
* @since 2.5.0
3636
* @see com.schooner.MemCached.MemcachedItem
3737
*/
3838
public final class MemcachedItem {

src/main/com/schooner/MemCached/ObjectTransCoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* serialization and deserialization in memcached operations.
4242
*
4343
* @author Xingen Wang
44-
* @since 2.5.1
44+
* @since 2.5.0
4545
* @see AbstractTransCoder
4646
* @see TransCoder
4747
*/

src/main/com/schooner/MemCached/SchoonerSockIO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* An adapter of com.danga.MemCached.SockIOPool.SockIO.
4242
*
4343
* @author Xingen Wang
44-
* @since 2.5.1
44+
* @since 2.5.0
4545
* @see SchoonerSockIO
4646
* @see com.danga.MemCached.SockIOPool.SockIO
4747
*/

src/main/com/schooner/MemCached/SchoonerSockIOPool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
* </pre>
115115
*
116116
* @author Xingen Wang
117-
* @since 2.5.1
117+
* @since 2.5.0
118118
* @see SchoonerSockIOPool
119119
*/
120120
public class SchoonerSockIOPool {

src/main/com/schooner/MemCached/SockInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* the byte length to read before invoke read.
3939
*
4040
* @author Xingen Wang
41-
* @since 2.5.1
41+
* @since 2.5.0
4242
* @see InputStream
4343
*/
4444
public final class SockInputStream extends InputStream {

0 commit comments

Comments
 (0)