Skip to content

Commit 2a3dd07

Browse files
authored
Merge branch 'master' into xread-block-2
2 parents 3ead3de + 66c8556 commit 2a3dd07

File tree

15 files changed

+210
-131
lines changed

15 files changed

+210
-131
lines changed

src/main/java/redis/clients/jedis/BinaryClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ public void zadd(final byte[] key, final Map<byte[], Double> scoreMembers, final
559559
sendCommand(ZADD, params.getByteParams(key, argsArray));
560560
}
561561

562+
public void zaddIncr(final byte[] key, final double score, final byte[] member, final ZAddParams params) {
563+
sendCommand(ZADD, params.getByteParams(key, INCR.getRaw(), toByteArray(score), member));
564+
}
565+
562566
public void zrange(final byte[] key, final long start, final long stop) {
563567
sendCommand(ZRANGE, key, toByteArray(start), toByteArray(stop));
564568
}

src/main/java/redis/clients/jedis/BinaryJedis.java

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,14 +1834,14 @@ public Long sunionstore(final byte[] dstkey, final byte[]... keys) {
18341834
* Return the difference between the Set stored at key1 and all the Sets key2, ..., keyN
18351835
* <p>
18361836
* <b>Example:</b>
1837-
*
1837+
*
18381838
* <pre>
18391839
* key1 = [x, a, b, c]
18401840
* key2 = [c]
18411841
* key3 = [a, d]
18421842
* SDIFF key1,key2,key3 =&gt; [x, b]
18431843
* </pre>
1844-
*
1844+
*
18451845
* Non existing keys are considered like empty sets.
18461846
* <p>
18471847
* <b>Time complexity:</b>
@@ -1941,6 +1941,13 @@ public Long zadd(final byte[] key, final Map<byte[], Double> scoreMembers, final
19411941
return client.getIntegerReply();
19421942
}
19431943

1944+
@Override
1945+
public Double zaddIncr(final byte[] key, final double score, final byte[] member, final ZAddParams params) {
1946+
checkIsInMultiOrPipeline();
1947+
client.zaddIncr(key, score, member, params);
1948+
return BuilderFactory.DOUBLE.build(client.getOne());
1949+
}
1950+
19441951
@Override
19451952
public Set<byte[]> zrange(final byte[] key, final long start, final long stop) {
19461953
checkIsInMultiOrPipeline();
@@ -2199,65 +2206,65 @@ public List<byte[]> sort(final byte[] key) {
21992206
* <b>examples:</b>
22002207
* <p>
22012208
* Given are the following sets and key/values:
2202-
*
2209+
*
22032210
* <pre>
22042211
* x = [1, 2, 3]
22052212
* y = [a, b, c]
2206-
*
2213+
*
22072214
* k1 = z
22082215
* k2 = y
22092216
* k3 = x
2210-
*
2217+
*
22112218
* w1 = 9
22122219
* w2 = 8
22132220
* w3 = 7
22142221
* </pre>
2215-
*
2222+
*
22162223
* Sort Order:
2217-
*
2224+
*
22182225
* <pre>
22192226
* sort(x) or sort(x, sp.asc())
22202227
* -&gt; [1, 2, 3]
2221-
*
2228+
*
22222229
* sort(x, sp.desc())
22232230
* -&gt; [3, 2, 1]
2224-
*
2231+
*
22252232
* sort(y)
22262233
* -&gt; [c, a, b]
2227-
*
2234+
*
22282235
* sort(y, sp.alpha())
22292236
* -&gt; [a, b, c]
2230-
*
2237+
*
22312238
* sort(y, sp.alpha().desc())
22322239
* -&gt; [c, a, b]
22332240
* </pre>
2234-
*
2241+
*
22352242
* Limit (e.g. for Pagination):
2236-
*
2243+
*
22372244
* <pre>
22382245
* sort(x, sp.limit(0, 2))
22392246
* -&gt; [1, 2]
2240-
*
2247+
*
22412248
* sort(y, sp.alpha().desc().limit(1, 2))
22422249
* -&gt; [b, a]
22432250
* </pre>
2244-
*
2251+
*
22452252
* Sorting by external keys:
2246-
*
2253+
*
22472254
* <pre>
22482255
* sort(x, sb.by(w*))
22492256
* -&gt; [3, 2, 1]
2250-
*
2257+
*
22512258
* sort(x, sb.by(w*).desc())
22522259
* -&gt; [1, 2, 3]
22532260
* </pre>
2254-
*
2261+
*
22552262
* Getting external keys:
2256-
*
2263+
*
22572264
* <pre>
22582265
* sort(x, sp.by(w*).get(k*))
22592266
* -&gt; [x, y, z]
2260-
*
2267+
*
22612268
* sort(x, sp.by(w*).get(#).get(k*))
22622269
* -&gt; [3, x, 2, y, 1, z]
22632270
* </pre>
@@ -3192,7 +3199,7 @@ public String shutdown() {
31923199
* <b>Format of the returned String:</b>
31933200
* <p>
31943201
* All the fields are in the form field:value
3195-
*
3202+
*
31963203
* <pre>
31973204
* edis_version:0.07
31983205
* connected_clients:1
@@ -3205,7 +3212,7 @@ public String shutdown() {
32053212
* uptime_in_seconds:25
32063213
* uptime_in_days:0
32073214
* </pre>
3208-
*
3215+
*
32093216
* <b>Notes</b>
32103217
* <p>
32113218
* used_memory is returned in bytes, and is the total number of bytes allocated by the program
@@ -3287,7 +3294,7 @@ public String slaveofNoOne() {
32873294
* are reported as a list of key-value pairs.
32883295
* <p>
32893296
* <b>Example:</b>
3290-
*
3297+
*
32913298
* <pre>
32923299
* $ redis-cli config get '*'
32933300
* 1. "dbfilename"
@@ -3302,7 +3309,7 @@ public String slaveofNoOne() {
33023309
* 10. "everysec"
33033310
* 11. "save"
33043311
* 12. "3600 1 300 100 60 10000"
3305-
*
3312+
*
33063313
* $ redis-cli config get 'm*'
33073314
* 1. "masterauth"
33083315
* 2. (nil)

src/main/java/redis/clients/jedis/BinaryJedisCluster.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,16 @@ public Long execute(Jedis connection) {
927927
}.runBinary(key);
928928
}
929929

930+
@Override
931+
public Double zaddIncr(byte[] key, double score, byte[] member, ZAddParams params) {
932+
return new JedisClusterCommand<Double>(connectionHandler, maxAttempts) {
933+
@Override
934+
public Double execute(Jedis connection) {
935+
return connection.zaddIncr(key, score, member, params);
936+
}
937+
}.runBinary(key);
938+
}
939+
930940
@Override
931941
public Set<byte[]> zrange(final byte[] key, final long start, final long stop) {
932942
return new JedisClusterCommand<Set<byte[]>>(connectionHandler, maxAttempts) {

src/main/java/redis/clients/jedis/BinaryShardedJedis.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,12 @@ public Long zadd(final byte[] key, final Map<byte[], Double> scoreMembers, final
525525
return j.zadd(key, scoreMembers, params);
526526
}
527527

528+
@Override
529+
public Double zaddIncr(final byte[] key, final double score, final byte[] member, final ZAddParams params) {
530+
Jedis j = getShard(key);
531+
return j.zaddIncr(key, score, member, params);
532+
}
533+
528534
@Override
529535
public Set<byte[]> zrange(final byte[] key, final long start, final long stop) {
530536
Jedis j = getShard(key);

src/main/java/redis/clients/jedis/Client.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@ public void zadd(final String key, final Map<String, Double> scoreMembers, final
464464
zadd(SafeEncoder.encode(key), binaryScoreMembers, params);
465465
}
466466

467+
@Override
468+
public void zaddIncr(final String key, final double score, final String member, final ZAddParams params) {
469+
zaddIncr(SafeEncoder.encode(key), score, SafeEncoder.encode(member), params);
470+
}
471+
467472
@Override
468473
public void zrange(final String key, final long start, final long stop) {
469474
zrange(SafeEncoder.encode(key), start, stop);
@@ -1412,7 +1417,7 @@ public void xreadGroup(String groupname, String consumer, int count, long block,
14121417
for (final Entry<String, StreamEntryID> entry : streams) {
14131418
bhash.put(SafeEncoder.encode(entry.getKey()), SafeEncoder.encode(entry.getValue()==null ? ">" : entry.getValue().toString()));
14141419
}
1415-
xreadGroup(SafeEncoder.encode(groupname), SafeEncoder.encode(consumer), count, block, noAck, bhash);
1420+
xreadGroup(SafeEncoder.encode(groupname), SafeEncoder.encode(consumer), count, block, noAck, bhash);
14161421
}
14171422

14181423
@Override
@@ -1443,7 +1448,7 @@ public void xreadGroup(String groupname, String consumer, XReadGroupParams param
14431448
public void xpending(String key, String groupname, StreamEntryID start, StreamEntryID end,
14441449
int count, String consumername) {
14451450
xpending(SafeEncoder.encode(key), SafeEncoder.encode(groupname), SafeEncoder.encode(start==null ? "-" : start.toString()),
1446-
SafeEncoder.encode(end==null ? "+" : end.toString()), count, consumername == null? null : SafeEncoder.encode(consumername));
1451+
SafeEncoder.encode(end==null ? "+" : end.toString()), count, consumername == null? null : SafeEncoder.encode(consumername));
14471452
}
14481453

14491454
@Override
@@ -1454,7 +1459,7 @@ public void xclaim(String key, String group, String consumername, long minIdleTi
14541459
for (int i = 0; i < ids.length; i++) {
14551460
bids[i] = SafeEncoder.encode(ids[i].toString());
14561461
}
1457-
xclaim(SafeEncoder.encode(key), SafeEncoder.encode(group), SafeEncoder.encode(consumername), minIdleTime, newIdleTime, retries, force, bids);
1462+
xclaim(SafeEncoder.encode(key), SafeEncoder.encode(group), SafeEncoder.encode(consumername), minIdleTime, newIdleTime, retries, force, bids);
14581463
}
14591464

14601465
@Override

src/main/java/redis/clients/jedis/Jedis.java

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,14 +1509,14 @@ public Long sunionstore(final String dstkey, final String... keys) {
15091509
* Return the difference between the Set stored at key1 and all the Sets key2, ..., keyN
15101510
* <p>
15111511
* <b>Example:</b>
1512-
*
1512+
*
15131513
* <pre>
15141514
* key1 = [x, a, b, c]
15151515
* key2 = [c]
15161516
* key3 = [a, d]
15171517
* SDIFF key1,key2,key3 =&gt; [x, b]
15181518
* </pre>
1519-
*
1519+
*
15201520
* Non existing keys are considered like empty sets.
15211521
* <p>
15221522
* <b>Time complexity:</b>
@@ -1616,6 +1616,13 @@ public Long zadd(final String key, final Map<String, Double> scoreMembers, final
16161616
return client.getIntegerReply();
16171617
}
16181618

1619+
@Override
1620+
public Double zaddIncr(final String key, final double score, final String member, final ZAddParams params) {
1621+
checkIsInMultiOrPipeline();
1622+
client.zaddIncr(key, score, member, params);
1623+
return BuilderFactory.DOUBLE.build(client.getOne());
1624+
}
1625+
16191626
@Override
16201627
public Set<String> zrange(final String key, final long start, final long stop) {
16211628
checkIsInMultiOrPipeline();
@@ -1852,65 +1859,65 @@ public List<String> sort(final String key) {
18521859
* <b>examples:</b>
18531860
* <p>
18541861
* Given are the following sets and key/values:
1855-
*
1862+
*
18561863
* <pre>
18571864
* x = [1, 2, 3]
18581865
* y = [a, b, c]
1859-
*
1866+
*
18601867
* k1 = z
18611868
* k2 = y
18621869
* k3 = x
1863-
*
1870+
*
18641871
* w1 = 9
18651872
* w2 = 8
18661873
* w3 = 7
18671874
* </pre>
1868-
*
1875+
*
18691876
* Sort Order:
1870-
*
1877+
*
18711878
* <pre>
18721879
* sort(x) or sort(x, sp.asc())
18731880
* -&gt; [1, 2, 3]
1874-
*
1881+
*
18751882
* sort(x, sp.desc())
18761883
* -&gt; [3, 2, 1]
1877-
*
1884+
*
18781885
* sort(y)
18791886
* -&gt; [c, a, b]
1880-
*
1887+
*
18811888
* sort(y, sp.alpha())
18821889
* -&gt; [a, b, c]
1883-
*
1890+
*
18841891
* sort(y, sp.alpha().desc())
18851892
* -&gt; [c, a, b]
18861893
* </pre>
1887-
*
1894+
*
18881895
* Limit (e.g. for Pagination):
1889-
*
1896+
*
18901897
* <pre>
18911898
* sort(x, sp.limit(0, 2))
18921899
* -&gt; [1, 2]
1893-
*
1900+
*
18941901
* sort(y, sp.alpha().desc().limit(1, 2))
18951902
* -&gt; [b, a]
18961903
* </pre>
1897-
*
1904+
*
18981905
* Sorting by external keys:
1899-
*
1906+
*
19001907
* <pre>
19011908
* sort(x, sb.by(w*))
19021909
* -&gt; [3, 2, 1]
1903-
*
1910+
*
19041911
* sort(x, sb.by(w*).desc())
19051912
* -&gt; [1, 2, 3]
19061913
* </pre>
1907-
*
1914+
*
19081915
* Getting external keys:
1909-
*
1916+
*
19101917
* <pre>
19111918
* sort(x, sp.by(w*).get(k*))
19121919
* -&gt; [x, y, z]
1913-
*
1920+
*
19141921
* sort(x, sp.by(w*).get(#).get(k*))
19151922
* -&gt; [3, x, 2, y, 1, z]
19161923
* </pre>
@@ -2852,7 +2859,7 @@ public Long bitpos(final String key, final boolean value, final BitPosParams par
28522859
* are reported as a list of key-value pairs.
28532860
* <p>
28542861
* <b>Example:</b>
2855-
*
2862+
*
28562863
* <pre>
28572864
* $ redis-cli config get '*'
28582865
* 1. "dbfilename"
@@ -2867,7 +2874,7 @@ public Long bitpos(final String key, final boolean value, final BitPosParams par
28672874
* 10. "everysec"
28682875
* 11. "save"
28692876
* 12. "3600 1 300 100 60 10000"
2870-
*
2877+
*
28712878
* $ redis-cli config get 'm*'
28722879
* 1. "masterauth"
28732880
* 2. (nil)
@@ -3117,7 +3124,7 @@ public Long bitop(final BitOP op, final String destKey, final String... srcKeys)
31173124
* 22) "2"
31183125
* 23) "quorum"
31193126
* 24) "2"
3120-
*
3127+
*
31213128
* </pre>
31223129
* @return
31233130
*/

src/main/java/redis/clients/jedis/JedisCluster.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,16 @@ public Long execute(Jedis connection) {
10291029
}.run(key);
10301030
}
10311031

1032+
@Override
1033+
public Double zaddIncr(String key, double score, String member, ZAddParams params) {
1034+
return new JedisClusterCommand<Double>(connectionHandler, maxAttempts) {
1035+
@Override
1036+
public Double execute(Jedis connection) {
1037+
return connection.zaddIncr(key, score, member, params);
1038+
}
1039+
}.run(key);
1040+
}
1041+
10321042
@Override
10331043
public Set<String> zrange(final String key, final long start, final long stop) {
10341044
return new JedisClusterCommand<Set<String>>(connectionHandler, maxAttempts) {

src/main/java/redis/clients/jedis/Protocol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public static enum Keyword {
282282
GETNAME, SETNAME, LIST, MATCH, COUNT, PING, PONG, UNLOAD, REPLACE, KEYS, PAUSE, DOCTOR, BLOCK,
283283
NOACK, STREAMS, KEY, CREATE, MKSTREAM, SETID, DESTROY, DELCONSUMER, MAXLEN, GROUP, ID, IDLE,
284284
TIME, RETRYCOUNT, FORCE, USAGE, SAMPLES, STREAM, GROUPS, CONSUMERS, HELP, FREQ, SETUSER,
285-
GETUSER, DELUSER, WHOAMI, CAT, GENPASS, USERS, LOG;
285+
GETUSER, DELUSER, WHOAMI, CAT, GENPASS, USERS, LOG, INCR;
286286

287287
/**
288288
* @deprecated This will be private in future. Use {@link #getRaw()}.

0 commit comments

Comments
 (0)