Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import redis.clients.jedis.params.ClientKillParams;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GeoRadiusStoreParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.MigrateParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
Expand Down Expand Up @@ -196,6 +197,10 @@ public void getDel(final byte[] key) {
sendCommand(GETDEL, key);
}

public void getEx(final byte[] key, final GetExParams params) {
sendCommand(GETEX, params.getByteParams(key));
}

public void quit() {
db = 0;
sendCommand(QUIT);
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import redis.clients.jedis.params.ClientKillParams;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GeoRadiusStoreParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.MigrateParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
Expand Down Expand Up @@ -413,6 +414,13 @@ public byte[] getDel(final byte[] key) {
return client.getBinaryBulkReply();
}

@Override
public byte[] getEx(final byte[] key, final GetExParams params) {
checkIsInMultiOrPipeline();
client.getEx(key, params);
return client.getBinaryBulkReply();
}

/**
* Ask the server to silently close the connection.
*/
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/redis/clients/jedis/BinaryJedisCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import redis.clients.jedis.commands.ProtocolCommand;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GeoRadiusStoreParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -199,6 +200,16 @@ public byte[] execute(Jedis connection) {
}.runBinary(key);
}

@Override
public byte[] getEx(byte[] key, GetExParams params) {
return new JedisClusterCommand<byte[]>(connectionHandler, maxAttempts) {
@Override
public byte[] execute(Jedis connection) {
return connection.getEx(key, params);
}
}.runBinary(key);
}

@Override
public Long exists(final byte[]... keys) {
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 @@ -11,6 +11,7 @@
import redis.clients.jedis.commands.ProtocolCommand;
import redis.clients.jedis.exceptions.JedisConnectionException;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -91,6 +92,12 @@ public byte[] getDel(final byte[] key) {
return j.getDel(key);
}

@Override
public byte[] getEx(byte[] key, GetExParams params) {
Jedis j = getShard(key);
return j.getEx(key, params);
}

@Override
public Boolean exists(final byte[] key) {
Jedis j = getShard(key);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/redis/clients/jedis/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import redis.clients.jedis.commands.Commands;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GeoRadiusStoreParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.MigrateParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
Expand Down Expand Up @@ -94,6 +95,11 @@ public void getDel(final String key) {
getDel(SafeEncoder.encode(key));
}

@Override
public void getEx(String key, GetExParams params) {
getEx(SafeEncoder.encode(key), params);
}

@Override
public void exists(final String... keys) {
exists(SafeEncoder.encodeMany(keys));
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 @@ -24,6 +24,7 @@
import redis.clients.jedis.commands.SentinelCommands;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GeoRadiusStoreParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.MigrateParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
Expand Down Expand Up @@ -244,6 +245,13 @@ public String getDel(final String key) {
return client.getBulkReply();
}

@Override
public String getEx(String key, GetExParams params) {
checkIsInMultiOrPipeline();
client.getEx(key, params);
return client.getBulkReply();
}

/**
* Test if the specified keys exist. The command returns the number of keys exist.
* Time complexity: O(N)
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/redis/clients/jedis/JedisCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import redis.clients.jedis.commands.ProtocolCommand;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GeoRadiusStoreParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -292,6 +293,16 @@ public String execute(Jedis connection) {
}.run(key);
}

@Override
public String getEx(String key, GetExParams params) {
return new JedisClusterCommand<String>(connectionHandler, maxAttempts) {
@Override
public String execute(Jedis connection) {
return connection.getEx(key, params);
}
}.run(key);
}

@Override
public Boolean exists(final String key) {
return new JedisClusterCommand<Boolean>(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 @@ -8,6 +8,7 @@
import redis.clients.jedis.commands.ProtocolCommand;
import redis.clients.jedis.commands.RedisPipeline;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -183,6 +184,18 @@ public Response<byte[]> getDel(final byte[] key) {
return getResponse(BuilderFactory.BYTE_ARRAY);
}

@Override
public Response<String> getEx(String key, GetExParams params) {
getClient(key).getEx(key, params);
return getResponse(BuilderFactory.STRING);
}

@Override
public Response<byte[]> getEx(byte[] key, GetExParams params) {
getClient(key).getEx(key, params);
return getResponse(BuilderFactory.BYTE_ARRAY);
}

@Override
public Response<Boolean> getbit(final String key, final long offset) {
getClient(key).getbit(key, offset);
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 @@ -243,7 +243,7 @@ public static final byte[] toByteArray(final double value) {
}

public static enum Command implements ProtocolCommand {
PING, SET, GET, GETDEL, QUIT, EXISTS, DEL, UNLINK, TYPE, FLUSHDB, KEYS, RANDOMKEY, RENAME,
PING, SET, GET, GETDEL, GETEX, QUIT, EXISTS, DEL, UNLINK, TYPE, FLUSHDB, KEYS, RANDOMKEY, RENAME,
RENAMENX, RENAMEX, DBSIZE, EXPIRE, EXPIREAT, TTL, SELECT, MOVE, FLUSHALL, GETSET, MGET, SETNX,
SETEX, MSET, MSETNX, DECRBY, DECR, INCRBY, INCR, APPEND, SUBSTR, HSET, HGET, HSETNX, HMSET,
HMGET, HINCRBY, HEXISTS, HDEL, HLEN, HKEYS, HVALS, HGETALL, RPUSH, LPUSH, LLEN, LRANGE, LTRIM,
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 @@ -10,6 +10,7 @@
import redis.clients.jedis.commands.JedisCommands;
import redis.clients.jedis.commands.ProtocolCommand;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -60,6 +61,12 @@ public String getDel(final String key) {
return j.getDel(key);
}

@Override
public String getEx(String key, GetExParams params) {
Jedis j = getShard(key);
return j.getEx(key, params);
}

@Override
public String echo(final String string) {
Jedis j = getShard(string);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import redis.clients.jedis.SortingParams;
import redis.clients.jedis.Tuple;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand All @@ -27,6 +28,8 @@ public interface BinaryJedisClusterCommands {

byte[] getDel(byte[] key);

byte[] getEx(byte[] key, GetExParams params);

Boolean exists(byte[] key);

Long persist(byte[] key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import redis.clients.jedis.StreamInfo;
import redis.clients.jedis.Tuple;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand All @@ -33,6 +34,8 @@ public interface BinaryJedisCommands {

byte[] getDel(byte[] key);

byte[] getEx(byte[] key, GetExParams params);

Boolean exists(byte[] key);

Long persist(byte[] key);
Expand Down
27 changes: 15 additions & 12 deletions src/main/java/redis/clients/jedis/commands/BinaryRedisPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import redis.clients.jedis.SortingParams;
import redis.clients.jedis.Tuple;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand Down Expand Up @@ -55,9 +56,11 @@ default Response<Long> expire(byte[] key, int seconds) {
Response<Long> pexpireAt(byte[] key, long millisecondsTimestamp);

Response<byte[]> get(byte[] key);

Response<byte[]> getDel(byte[] key);

Response<byte[]> getEx(byte[] key, GetExParams params);

Response<Boolean> getbit(byte[] key, long offset);

Response<byte[]> getSet(byte[] key, byte[] value);
Expand Down Expand Up @@ -345,7 +348,7 @@ Response<List<GeoRadiusResponse>> georadiusByMember(byte[] key, byte[] member, d

Response<List<GeoRadiusResponse>> georadiusByMemberReadonly(byte[] key, byte[] member,
double radius, GeoUnit unit);

Response<List<GeoRadiusResponse>> georadiusByMember(byte[] key, byte[] member, double radius,
GeoUnit unit, GeoRadiusParam param);

Expand All @@ -357,25 +360,25 @@ Response<List<GeoRadiusResponse>> georadiusByMemberReadonly(byte[] key, byte[] m
Response<List<Long>> bitfieldReadonly(byte[] key, byte[]... elements);

Response<Long> hstrlen(byte[] key, byte[] field);

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

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

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

Response<List<byte[]>> xrange(byte[] key, byte[] start, byte[] end, int count);

Response<List<byte[]>> xrevrange(byte[] key, byte[] end, byte[] start, int count);

Response<Long> xack(byte[] key, byte[] group, byte[]... ids);

Response<String> xgroupCreate(byte[] key, byte[] groupname, byte[] id, boolean makeStream);

Response<String> xgroupSetID(byte[] key, byte[] groupname, byte[] id);

Response<Long> xgroupDestroy(byte[] key, byte[] groupname);

Response<Long> xgroupDelConsumer(byte[] key, byte[] groupname, byte[] consumername);

/**
Expand All @@ -387,10 +390,10 @@ Response<List<GeoRadiusResponse>> georadiusByMemberReadonly(byte[] key, byte[] m
Response<List<Object>> xpendingBinary(byte[] key, byte[] groupname, byte[] start, byte[] end, int count, byte[] consumername);

Response<Long> xdel(byte[] key, byte[]... ids);

Response<Long> xtrim(byte[] key, long maxLen, boolean approximateLength);
Response<List<byte[]>> xclaim(byte[] key, byte[] group, byte[] consumername, long minIdleTime,

Response<List<byte[]>> xclaim(byte[] key, byte[] group, byte[] consumername, long minIdleTime,
long newIdleTime, int retries, boolean force, byte[]... ids);

Response<Long> bitpos(byte[] key, boolean value);
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 @@ -9,6 +9,7 @@
import redis.clients.jedis.ScanParams;
import redis.clients.jedis.SortingParams;
import redis.clients.jedis.ZParams;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.MigrateParams;
import redis.clients.jedis.params.ClientKillParams;
import redis.clients.jedis.params.SetParams;
Expand All @@ -28,6 +29,8 @@ public interface Commands {

void getDel(String key);

void getEx(String key, GetExParams params);

void exists(String... keys);

void del(String... keys);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package redis.clients.jedis.commands;

import redis.clients.jedis.Response;
import redis.clients.jedis.StreamEntryID;
import redis.clients.jedis.GeoCoordinate;
import redis.clients.jedis.GeoRadiusResponse;
Expand All @@ -12,6 +13,7 @@
import redis.clients.jedis.StreamPendingSummary;
import redis.clients.jedis.Tuple;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand All @@ -30,6 +32,8 @@ public interface JedisClusterCommands {

String getDel(String key);

String getEx(String key, GetExParams params);

Boolean exists(String key);

Long persist(String key);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/redis/clients/jedis/commands/JedisCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import redis.clients.jedis.StreamPendingSummary;
import redis.clients.jedis.Tuple;
import redis.clients.jedis.params.GeoRadiusParam;
import redis.clients.jedis.params.GetExParams;
import redis.clients.jedis.params.SetParams;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
Expand All @@ -38,6 +39,8 @@ public interface JedisCommands {

String getDel(String key);

String getEx(String key, GetExParams params);

Boolean exists(String key);

Long persist(String key);
Expand Down
Loading