Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2f6dc3e

Browse files
committed
Polishing.
Switch Jedis XADD call to XAddParams. See #2047 Original pull request: #2118.
1 parent f3f0c11 commit 2f6dc3e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

‎src/main/java/org/springframework/data/redis/connection/jedis/JedisStreamCommands.java‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import redis.clients.jedis.MultiKeyPipelineBase;
2121
import redis.clients.jedis.StreamConsumersInfo;
2222
import redis.clients.jedis.StreamGroupInfo;
23+
import redis.clients.jedis.params.XAddParams;
2324

2425
import java.util.ArrayList;
2526
import java.util.Arrays;
@@ -78,14 +79,18 @@ public RecordId xAdd(MapRecord<byte[], byte[], byte[]> record, XAddOptions optio
7879
Assert.notNull(record, "Record must not be null!");
7980
Assert.notNull(record.getStream(), "Stream must not be null!");
8081

81-
byte[] id = JedisConverters.toBytes(record.getId().getValue());
82-
longmaxLength = Long.MAX_VALUE;
82+
XAddParamsxAddParams = newXAddParams();
83+
xAddParams.id(record.getId().getValue());
8384
if (options.hasMaxlen()) {
84-
maxLength = options.getMaxlen();
85+
xAddParams.maxLen(options.getMaxlen());
86+
}
87+
if (options.isNoMkStream()) {
88+
xAddParams.noMkStream();
8589
}
8690

87-
return connection.invoke().from(BinaryJedis::xadd, MultiKeyPipelineBase::xadd, record.getStream(), id,
88-
record.getValue(), maxLength, false).get(it -> RecordId.of(JedisConverters.toString(it)));
91+
return connection.invoke()
92+
.from(BinaryJedis::xadd, MultiKeyPipelineBase::xadd, record.getStream(), record.getValue(), xAddParams)
93+
.get(it -> RecordId.of(JedisConverters.toString(it)));
8994
}
9095

9196
/*

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /