extracted interfaces from Jedis
This commit is contained in:
@@ -13,7 +13,7 @@ import redis.clients.jedis.BinaryClient.LIST_POSITION;
|
||||
import redis.clients.util.SafeEncoder;
|
||||
import redis.clients.util.Slowlog;
|
||||
|
||||
public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommands, JedisBasicCommands {
|
||||
public Jedis(final String host) {
|
||||
super(host);
|
||||
}
|
||||
@@ -114,6 +114,11 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public Long del(String key) {
|
||||
client.del(key);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type of the value stored at key in form of a string. The type
|
||||
* can be one of "none", "string", "list", "set". "none" is returned if the
|
||||
@@ -1817,6 +1822,42 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
return multiBulkReply;
|
||||
}
|
||||
|
||||
public List<String> blpop(String... args) {
|
||||
client.blpop(args);
|
||||
client.setTimeoutInfinite();
|
||||
final List<String> multiBulkReply = client.getMultiBulkReply();
|
||||
client.rollbackTimeout();
|
||||
return multiBulkReply;
|
||||
}
|
||||
|
||||
public List<String> brpop(String... args) {
|
||||
client.brpop(args);
|
||||
client.setTimeoutInfinite();
|
||||
final List<String> multiBulkReply = client.getMultiBulkReply();
|
||||
client.rollbackTimeout();
|
||||
return multiBulkReply;
|
||||
}
|
||||
|
||||
public List<String> blpop(String arg) {
|
||||
String[] args = new String[1];
|
||||
args[0] = arg;
|
||||
client.blpop(args);
|
||||
client.setTimeoutInfinite();
|
||||
final List<String> multiBulkReply = client.getMultiBulkReply();
|
||||
client.rollbackTimeout();
|
||||
return multiBulkReply;
|
||||
}
|
||||
|
||||
public List<String> brpop(String arg) {
|
||||
String[] args = new String[1];
|
||||
args[0] = arg;
|
||||
client.brpop(args);
|
||||
client.setTimeoutInfinite();
|
||||
final List<String> multiBulkReply = client.getMultiBulkReply();
|
||||
client.rollbackTimeout();
|
||||
return multiBulkReply;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort a Set or a List accordingly to the specified parameters and store
|
||||
* the result at dstkey.
|
||||
|
||||
40
src/main/java/redis/clients/jedis/JedisBasicCommands.java
Normal file
40
src/main/java/redis/clients/jedis/JedisBasicCommands.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import redis.clients.util.Slowlog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface JedisBasicCommands {
|
||||
List<String> configGet(String pattern);
|
||||
|
||||
String configSet(String parameter, String value);
|
||||
|
||||
Object eval(String script, int keyCount, String... params);
|
||||
|
||||
Object eval(String script, List<String> keys, List<String> args);
|
||||
|
||||
Object eval(String script);
|
||||
|
||||
Object evalsha(String script);
|
||||
|
||||
Object evalsha(String sha1, List<String> keys, List<String> args);
|
||||
|
||||
Object evalsha(String sha1, int keyCount, String... params);
|
||||
|
||||
Boolean scriptExists(String sha1);
|
||||
|
||||
List<Boolean> scriptExists(String... sha1);
|
||||
|
||||
String scriptLoad(String script);
|
||||
|
||||
List<Slowlog> slowlogGet();
|
||||
|
||||
List<Slowlog> slowlogGet(long entries);
|
||||
|
||||
Long objectRefcount(String string);
|
||||
|
||||
String objectEncoding(String string);
|
||||
|
||||
Long objectIdletime(String string);
|
||||
}
|
||||
@@ -14,6 +14,8 @@ public interface JedisCommands {
|
||||
|
||||
Boolean exists(String key);
|
||||
|
||||
Long persist(String key);
|
||||
|
||||
String type(String key);
|
||||
|
||||
Long expire(String key, int seconds);
|
||||
@@ -106,6 +108,8 @@ public interface JedisCommands {
|
||||
|
||||
String srandmember(String key);
|
||||
|
||||
Long strlen(String key);
|
||||
|
||||
Long zadd(String key, double score, String member);
|
||||
|
||||
Long zadd(String key, Map<Double, String> scoreMembers);
|
||||
@@ -190,4 +194,14 @@ public interface JedisCommands {
|
||||
Long lpushx(String key, String string);
|
||||
|
||||
Long rpushx(String key, String string);
|
||||
|
||||
List<String> blpop(String arg);
|
||||
|
||||
List<String> brpop(String arg);
|
||||
|
||||
Long del(String key);
|
||||
|
||||
String echo(String string);
|
||||
|
||||
Long move(String key, int dbIndex);
|
||||
}
|
||||
|
||||
65
src/main/java/redis/clients/jedis/MultiKeyCommands.java
Normal file
65
src/main/java/redis/clients/jedis/MultiKeyCommands.java
Normal file
@@ -0,0 +1,65 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface MultiKeyCommands {
|
||||
Long del(String... keys);
|
||||
|
||||
List<String> blpop(int timeout, String... keys);
|
||||
|
||||
List<String> brpop(int timeout, String... keys);
|
||||
|
||||
List<String> blpop(String... args);
|
||||
|
||||
List<String> brpop(String... args);
|
||||
|
||||
Set<String> keys(String pattern);
|
||||
|
||||
List<String> mget(String... keys);
|
||||
|
||||
String mset(String... keysvalues);
|
||||
|
||||
Long msetnx(String... keysvalues);
|
||||
|
||||
String rename(String oldkey, String newkey);
|
||||
|
||||
Long renamenx(String oldkey, String newkey);
|
||||
|
||||
String rpoplpush(String srckey, String dstkey);
|
||||
|
||||
Set<String> sdiff(String... keys);
|
||||
|
||||
Long sdiffstore(String dstkey, String... keys);
|
||||
|
||||
Set<String> sinter(String... keys);
|
||||
|
||||
Long sinterstore(String dstkey, String... keys);
|
||||
|
||||
Long smove(String srckey, String dstkey, String member);
|
||||
|
||||
Long sort(String key, SortingParams sortingParameters, String dstkey);
|
||||
|
||||
Long sort(String key, String dstkey);
|
||||
|
||||
Set<String> sunion(String... keys);
|
||||
|
||||
Long sunionstore(String dstkey, String... keys);
|
||||
|
||||
String watch(String... keys);
|
||||
|
||||
Long zinterstore(String dstkey, String... sets);
|
||||
|
||||
Long zinterstore(String dstkey, ZParams params, String... sets);
|
||||
|
||||
Long zunionstore(String dstkey, String... sets);
|
||||
|
||||
Long zunionstore(String dstkey, ZParams params, String... sets);
|
||||
|
||||
String brpoplpush(String source, String destination, int timeout);
|
||||
|
||||
Long publish(String channel, String message);
|
||||
|
||||
String randomKey();
|
||||
}
|
||||
@@ -43,6 +43,11 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
return j.get(key);
|
||||
}
|
||||
|
||||
public String echo(String string) {
|
||||
Jedis j = getShard(string);
|
||||
return j.echo(string);
|
||||
}
|
||||
|
||||
public Boolean exists(String key) {
|
||||
Jedis j = getShard(key);
|
||||
return j.exists(key);
|
||||
@@ -103,6 +108,16 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
return j.setex(key, seconds, value);
|
||||
}
|
||||
|
||||
public List<String> blpop(String arg) {
|
||||
Jedis j = getShard(arg);
|
||||
return j.blpop(arg);
|
||||
}
|
||||
|
||||
public List<String> brpop(String arg) {
|
||||
Jedis j = getShard(arg);
|
||||
return j.brpop(arg);
|
||||
}
|
||||
|
||||
public Long decrBy(String key, long integer) {
|
||||
Jedis j = getShard(key);
|
||||
return j.decrBy(key, integer);
|
||||
@@ -218,6 +233,11 @@ public class ShardedJedis extends BinaryShardedJedis implements JedisCommands {
|
||||
return j.strlen(key);
|
||||
}
|
||||
|
||||
public Long move(String key, int dbIndex) {
|
||||
Jedis j = getShard(key);
|
||||
return j.move(key, dbIndex);
|
||||
}
|
||||
|
||||
public Long rpushx(String key, String string) {
|
||||
Jedis j = getShard(key);
|
||||
return j.rpushx(key, string);
|
||||
|
||||
Reference in New Issue
Block a user