Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,16 @@ public void xadd(final byte[] key, final byte[] id, final Map<byte[], byte[]> ha
sendCommand(XADD, params);
}

public void xadd(final byte[] key, final Map<byte[], byte[]> hash, final XAddParams xAddParams) {
final byte[][] params = new byte[hash.size() * 2][];
int index = 0;
for (final Entry<byte[], byte[]> entry : hash.entrySet()) {
params[index++] = entry.getKey();
params[index++] = entry.getValue();
}
sendCommand(XADD, xAddParams.getByteParams(key, params));
}

public void xlen(final byte[] key) {
sendCommand(XLEN, key);
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -4610,6 +4610,13 @@ public byte[] xadd(byte[] key, byte[] id, Map<byte[], byte[]> hash, long maxLen,
return client.getBinaryBulkReply();
}

@Override
public byte[] xadd(final byte[] key, final Map<byte[], byte[]> hash, final XAddParams params) {
checkIsInMultiOrPipeline();
client.xadd(key, hash, params);
return client.getBinaryBulkReply();
}

@Override
public Long xlen(byte[] key) {
checkIsInMultiOrPipeline();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryJedisCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -2427,6 +2427,16 @@ public byte[] execute(Jedis connection) {
}.runBinary(key);
}

@Override
public byte[] xadd(final byte[] key, final Map<byte[], byte[]> hash, final XAddParams params) {
return new JedisClusterCommand<byte[]>(connectionHandler, maxAttempts) {
@Override
public byte[] execute(Jedis connection) {
return connection.xadd(key, hash, params);
}
}.runBinary(key);
}

@Override
public Long xlen(final byte[] key) {
return new JedisClusterCommand<Long>(connectionHandler, maxAttempts) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryShardedJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.XAddParams;
import redis.clients.jedis.params.XClaimParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -1133,6 +1134,12 @@ public byte[] xadd(byte[] key, byte[] id, Map<byte[], byte[]> hash, long maxLen,
return j.xadd(key, id, hash, maxLen, approximateLength);
}

@Override
public byte[] xadd(final byte[] key, final Map<byte[], byte[]> hash, final XAddParams params) {
Jedis j = getShard(key);
return j.xadd(key, hash, params);
}

@Override
public Long xlen(byte[] key) {
Jedis j = getShard(key);
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/redis/clients/jedis/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -1363,12 +1363,13 @@ public void hstrlen(final String key, final String field) {
@Override
public void xadd(final String key, final StreamEntryID id, final Map<String, String> hash,
long maxLen, boolean approximateLength) {
final Map<byte[], byte[]> bhash = new HashMap<>(hash.size());
for (final Entry<String, String> entry : hash.entrySet()) {
bhash.put(SafeEncoder.encode(entry.getKey()), SafeEncoder.encode(entry.getValue()));
}
xadd(SafeEncoder.encode(key), SafeEncoder.encode(id == null ? "*" : id.toString()), bhash,
maxLen, approximateLength);
xadd(SafeEncoder.encode(key), SafeEncoder.encode(id == null ? "*" : id.toString()),
SafeEncoder.encodeStringMap(hash), maxLen, approximateLength);
}

@Override
public void xadd(final String key, final Map<String, String> hash, final XAddParams params) {
xadd(SafeEncoder.encode(key), SafeEncoder.encodeStringMap(hash), params);
}

@Override
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -4086,6 +4086,14 @@ public StreamEntryID xadd(final String key, StreamEntryID id, final Map<String,
return new StreamEntryID(result);
}

@Override
public StreamEntryID xadd(final String key, final Map<String, String> hash, final XAddParams params) {
checkIsInMultiOrPipeline();
client.xadd(key, hash, params);
String result = client.getBulkReply();
return result == null ? null : new StreamEntryID(result);
}

@Override
public Long xlen(final String key) {
checkIsInMultiOrPipeline();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/redis/clients/jedis/JedisCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -2507,6 +2507,16 @@ public StreamEntryID execute(Jedis connection) {
}.run(key);
}

@Override
public StreamEntryID xadd(final String key, final Map<String, String> hash, final XAddParams params) {
return new JedisClusterCommand<StreamEntryID>(connectionHandler, maxAttempts) {
@Override
public StreamEntryID execute(Jedis connection) {
return connection.xadd(key, hash, params);
}
}.run(key);
}

@Override
public Long xlen(final String key) {
return new JedisClusterCommand<Long>(connectionHandler, maxAttempts) {
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/redis/clients/jedis/PipelineBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.XAddParams;
import redis.clients.jedis.params.XClaimParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -2124,6 +2125,18 @@ public Response<byte[]> xadd(byte[] key, byte[] id, Map<byte[], byte[]> hash, lo
return getResponse(BuilderFactory.BYTE_ARRAY);
}

@Override
public Response<byte[]> xadd(final byte[] key, final Map<byte[], byte[]> hash, final XAddParams params) {
getClient(key).xadd(key, hash, params);
return getResponse(BuilderFactory.BYTE_ARRAY);
}

@Override
public Response<StreamEntryID> xadd(final String key, final Map<String, String> hash, final XAddParams params) {
getClient(key).xadd(key, hash, params);
return getResponse(BuilderFactory.STREAM_ENTRY_ID);
}

@Override
public Response<Long> xlen(String key) {
getClient(key).xlen(key);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/redis/clients/jedis/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public static enum Keyword implements Rawable {
GETNAME, SETNAME, LIST, MATCH, COUNT, PING, PONG, UNLOAD, REPLACE, KEYS, PAUSE, DOCTOR, BLOCK,
NOACK, STREAMS, KEY, CREATE, MKSTREAM, SETID, DESTROY, DELCONSUMER, MAXLEN, GROUP, ID, IDLE,
TIME, RETRYCOUNT, FORCE, USAGE, SAMPLES, STREAM, GROUPS, CONSUMERS, HELP, FREQ, SETUSER,
GETUSER, DELUSER, WHOAMI, CAT, GENPASS, USERS, LOG, INCR, SAVE, JUSTID, WITHVALUES, UNBLOCK;
GETUSER, DELUSER, WHOAMI, CAT, GENPASS, USERS, LOG, INCR, SAVE, JUSTID, WITHVALUES, UNBLOCK, NOMKSTREAM, MINID;

/**
* @deprecated This will be private in future. Use {@link #getRaw()}.
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/redis/clients/jedis/ShardedJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.XAddParams;
import redis.clients.jedis.params.XClaimParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -1129,6 +1130,12 @@ public StreamEntryID xadd(String key, StreamEntryID id, Map<String, String> hash
return j.xadd(key, id, hash, maxLen, approximateLength);
}

@Override
public StreamEntryID xadd(final String key, final Map<String, String> hash, final XAddParams params) {
Jedis j = getShard(key);
return j.xadd(key, hash, params);
}

@Override
public Long xlen(String key) {
Jedis j = getShard(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.XAddParams;
import redis.clients.jedis.params.XClaimParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -385,6 +386,8 @@ List<GeoRadiusResponse> georadiusByMemberReadonly(byte[] key, byte[] member, dou

byte[] xadd(byte[] key, byte[] id, Map<byte[], byte[]> hash, long maxLen, boolean approximateLength);

byte[] xadd(byte[] key, Map<byte[], byte[]> hash, XAddParams params);

Long xlen(byte[] key);

List<byte[]> xrange(byte[] key, byte[] start, byte[] end);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
import redis.clients.jedis.ScanResult;
import redis.clients.jedis.SortingParams;
import redis.clients.jedis.StreamConsumersInfo;
import redis.clients.jedis.StreamEntryID;
import redis.clients.jedis.StreamGroupInfo;
import redis.clients.jedis.StreamInfo;
import redis.clients.jedis.Tuple;
import redis.clients.jedis.params.GeoAddParams;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.XAddParams;
import redis.clients.jedis.params.XClaimParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -413,6 +415,8 @@ List<GeoRadiusResponse> georadiusByMemberReadonly(byte[] key, byte[] member, dou

byte[] xadd(byte[] key, byte[] id, Map<byte[], byte[]> hash, long maxLen, boolean approximateLength);

byte[] xadd(byte[] key, Map<byte[], byte[]> hash, XAddParams params);

Long xlen(byte[] key);

List<byte[]> xrange(byte[] key, byte[] start, byte[] end);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import redis.clients.jedis.GeoRadiusResponse;
import redis.clients.jedis.GeoUnit;
import redis.clients.jedis.ListPosition;
import redis.clients.jedis.StreamEntryID;
import redis.clients.jedis.StreamPendingEntry;
import redis.clients.jedis.Response;
import redis.clients.jedis.SortingParams;
Expand All @@ -13,6 +14,7 @@
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.XAddParams;
import redis.clients.jedis.params.XClaimParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -383,6 +385,8 @@ Response<List<GeoRadiusResponse>> georadiusByMemberReadonly(byte[] key, byte[] m

Response<byte[]> xadd(byte[] key, byte[] id, Map<byte[], byte[]> hash, long maxLen, boolean approximateLength);

Response<byte[]> xadd(byte[] key, Map<byte[], byte[]> hash, XAddParams params);

Response<Long> xlen(byte[] key);

Response<List<byte[]>> xrange(byte[] key, byte[] start, byte[] end);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/redis/clients/jedis/commands/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import redis.clients.jedis.params.MigrateParams;
import redis.clients.jedis.params.ClientKillParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.XAddParams;
import redis.clients.jedis.params.XClaimParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -449,6 +450,8 @@ default void restoreReplace(String key, int ttl, byte[] serializedValue) {

void xadd(String key, StreamEntryID id, Map<String, String> hash, long maxLen, boolean approximateLength);

void xadd(String key, Map<String, String> hash, XAddParams params);

void xlen(String key);

void xrange(String key, StreamEntryID start, StreamEntryID end);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.XAddParams;
import redis.clients.jedis.params.XClaimParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -433,6 +434,16 @@ List<GeoRadiusResponse> georadiusByMemberReadonly(String key, String member, dou
*/
StreamEntryID xadd(String key, StreamEntryID id, Map<String, String> hash, long maxLen, boolean approximateLength);

/**
* XADD key [NOMKSTREAM] [MAXLEN|MINID [=|~] threshold [LIMIT count]] *|ID field value [field value ...]
*
* @param key
* @param hash
* @param params
* @return
*/
StreamEntryID xadd(String key, Map<String, String> hash, XAddParams params);

/**
* XLEN key
*
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/redis/clients/jedis/commands/JedisCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.XAddParams;
import redis.clients.jedis.params.XClaimParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -446,6 +447,16 @@ List<GeoRadiusResponse> georadiusByMemberReadonly(String key, String member, dou
*/
StreamEntryID xadd(String key, StreamEntryID id, Map<String, String> hash, long maxLen, boolean approximateLength);

/**
* XADD key [NOMKSTREAM] [MAXLEN|MINID [=|~] threshold [LIMIT count]] *|ID field value [field value ...]
*
* @param key
* @param hash
* @param params
* @return
*/
StreamEntryID xadd(String key, Map<String, String> hash, XAddParams params);

/**
* XLEN key
*
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/redis/clients/jedis/commands/RedisPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.XAddParams;
import redis.clients.jedis.params.XClaimParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -380,6 +381,8 @@ Response<List<GeoRadiusResponse>> georadiusByMemberReadonly(String key, String m

Response<StreamEntryID> xadd(String key, StreamEntryID id, Map<String, String> hash, long maxLen, boolean approximateLength);

Response<StreamEntryID> xadd(String key, Map<String, String> hash, XAddParams params);

Response<Long> xlen(String key);

Response<List<StreamEntry>> xrange(String key, StreamEntryID start, StreamEntryID end);
Expand Down
Loading