added interfaces for ScriptingCommands, AdvancedCommands most of jedis and binaryjedis are defined by interfaces
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AdvancedBinaryJedisCommands {
|
||||
|
||||
List<byte[]> configGet(byte[] pattern);
|
||||
|
||||
byte[] configSet(byte[] parameter, byte[] value);
|
||||
|
||||
String slowlogReset();
|
||||
|
||||
Long slowlogLen();
|
||||
|
||||
List<byte[]> slowlogGetBinary();
|
||||
|
||||
List<byte[]> slowlogGetBinary(long entries);
|
||||
|
||||
Long objectRefcount(byte[] key);
|
||||
|
||||
byte[] objectEncoding(byte[] key);
|
||||
|
||||
Long objectIdletime(byte[] key);
|
||||
}
|
||||
26
src/main/java/redis/clients/jedis/AdvancedJedisCommands.java
Normal file
26
src/main/java/redis/clients/jedis/AdvancedJedisCommands.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import redis.clients.util.Slowlog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface AdvancedJedisCommands {
|
||||
List<String> configGet(String pattern);
|
||||
|
||||
String configSet(String parameter, String value);
|
||||
|
||||
String slowlogReset();
|
||||
|
||||
Long slowlogLen();
|
||||
|
||||
List<Slowlog> slowlogGet();
|
||||
|
||||
List<Slowlog> slowlogGet(long entries);
|
||||
|
||||
Long objectRefcount(String string);
|
||||
|
||||
String objectEncoding(String string);
|
||||
|
||||
Long objectIdletime(String string);
|
||||
}
|
||||
40
src/main/java/redis/clients/jedis/BasicCommands.java
Normal file
40
src/main/java/redis/clients/jedis/BasicCommands.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
public interface BasicCommands {
|
||||
|
||||
String ping();
|
||||
|
||||
String quit();
|
||||
|
||||
String flushDB();
|
||||
|
||||
Long dbSize();
|
||||
|
||||
String select(int index);
|
||||
|
||||
String flushAll();
|
||||
|
||||
String auth(String password);
|
||||
|
||||
String save();
|
||||
|
||||
String bgsave();
|
||||
|
||||
String bgrewriteaof();
|
||||
|
||||
Long lastsave();
|
||||
|
||||
String shutdown();
|
||||
|
||||
String info();
|
||||
|
||||
String slaveof(String host, int port);
|
||||
|
||||
String slaveofNoOne();
|
||||
|
||||
Long getDB();
|
||||
|
||||
String debug(DebugParams params);
|
||||
|
||||
String configResetStat();
|
||||
}
|
||||
@@ -759,10 +759,18 @@ public class BinaryClient extends Connection {
|
||||
sendEvalCommand(EVAL, script, keyCount, params);
|
||||
}
|
||||
|
||||
public void evalsha(byte[] sha1, byte[] keyCount, byte[][] params) {
|
||||
public void eval(byte[] script, int keyCount, byte[]... params) {
|
||||
eval(script, toByteArray(keyCount), params);
|
||||
}
|
||||
|
||||
public void evalsha(byte[] sha1, byte[] keyCount, byte[]... params) {
|
||||
sendEvalCommand(EVALSHA, sha1, keyCount, params);
|
||||
}
|
||||
|
||||
public void evalsha(byte[] sha1, int keyCount, byte[]... params) {
|
||||
sendEvalCommand(EVALSHA, sha1, toByteArray(keyCount), params);
|
||||
}
|
||||
|
||||
public void scriptFlush() {
|
||||
sendCommand(SCRIPT, Keyword.FLUSH.raw);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import redis.clients.jedis.exceptions.JedisException;
|
||||
import redis.clients.util.JedisByteHashMap;
|
||||
import redis.clients.util.SafeEncoder;
|
||||
|
||||
public class BinaryJedis implements BinaryJedisCommands, MultiKeyBinaryCommands {
|
||||
public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKeyBinaryCommands, AdvancedBinaryJedisCommands, BinaryScriptingCommands {
|
||||
protected Client client = null;
|
||||
|
||||
public BinaryJedis(final String host) {
|
||||
@@ -2108,29 +2108,6 @@ public class BinaryJedis implements BinaryJedisCommands, MultiKeyBinaryCommands
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
public void subscribe(final JedisPubSub jedisPubSub,
|
||||
final String... channels) {
|
||||
client.setTimeoutInfinite();
|
||||
jedisPubSub.proceed(client, channels);
|
||||
client.rollbackTimeout();
|
||||
}
|
||||
|
||||
public Long publish(final String channel, final String message) {
|
||||
checkIsInMulti();
|
||||
connect();
|
||||
client.publish(channel, message);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public void psubscribe(final JedisPubSub jedisPubSub,
|
||||
final String... patterns) {
|
||||
checkIsInMulti();
|
||||
connect();
|
||||
client.setTimeoutInfinite();
|
||||
jedisPubSub.proceedWithPatterns(client, patterns);
|
||||
client.rollbackTimeout();
|
||||
}
|
||||
|
||||
public Long zcount(final byte[] key, final double min, final double max) {
|
||||
return zcount(key, toByteArray(min), toByteArray(max));
|
||||
}
|
||||
@@ -3151,20 +3128,50 @@ public class BinaryJedis implements BinaryJedisCommands, MultiKeyBinaryCommands
|
||||
return params;
|
||||
}
|
||||
|
||||
public Object eval(byte[] script, byte[] keyCount, byte[][] params) {
|
||||
public Object eval(byte[] script, byte[] keyCount, byte[]... params) {
|
||||
client.setTimeoutInfinite();
|
||||
client.eval(script, keyCount, params);
|
||||
return client.getOne();
|
||||
}
|
||||
|
||||
public byte[] scriptFlush() {
|
||||
public Object eval(byte[] script, int keyCount, byte[]... params) {
|
||||
client.setTimeoutInfinite();
|
||||
client.eval(script, SafeEncoder.encode(Integer.toString(keyCount)), params);
|
||||
return client.getOne();
|
||||
}
|
||||
|
||||
public Object eval(byte[] script) {
|
||||
client.setTimeoutInfinite();
|
||||
client.eval(script, 0);
|
||||
return client.getOne();
|
||||
}
|
||||
|
||||
public Object evalsha(byte[] sha1) {
|
||||
client.setTimeoutInfinite();
|
||||
client.evalsha(sha1, 0);
|
||||
return client.getOne();
|
||||
}
|
||||
|
||||
public Object evalsha(byte[] sha1, List<byte[]> keys, List<byte[]> args) {
|
||||
client.setTimeoutInfinite();
|
||||
client.evalsha(sha1, keys.size(), keys.toArray(new byte[0][]));
|
||||
return client.getOne();
|
||||
}
|
||||
|
||||
public Object evalsha(byte[] sha1, int keyCount, byte[]... params) {
|
||||
client.setTimeoutInfinite();
|
||||
client.evalsha(sha1, keyCount, params);
|
||||
return client.getOne();
|
||||
}
|
||||
|
||||
public String scriptFlush() {
|
||||
client.scriptFlush();
|
||||
return client.getBinaryBulkReply();
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public List<Long> scriptExists(byte[]... sha1) {
|
||||
client.scriptExists(sha1);
|
||||
return client.getIntegerMultiBulkReply();
|
||||
return client.getIntegerMultiBulkReply();
|
||||
}
|
||||
|
||||
public byte[] scriptLoad(byte[] script) {
|
||||
@@ -3172,17 +3179,17 @@ public class BinaryJedis implements BinaryJedisCommands, MultiKeyBinaryCommands
|
||||
return client.getBinaryBulkReply();
|
||||
}
|
||||
|
||||
public byte[] scriptKill() {
|
||||
public String scriptKill() {
|
||||
client.scriptKill();
|
||||
return client.getBinaryBulkReply();
|
||||
return client.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public byte[] slowlogReset() {
|
||||
public String slowlogReset() {
|
||||
client.slowlogReset();
|
||||
return client.getBinaryBulkReply();
|
||||
return client.getBulkReply();
|
||||
}
|
||||
|
||||
public long slowlogLen() {
|
||||
public Long slowlogLen() {
|
||||
client.slowlogLen();
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BinaryScriptingCommands {
|
||||
|
||||
Object eval(byte[] script, byte[] keyCount, byte[]... params);
|
||||
|
||||
Object eval(byte[] script, int keyCount, byte[]... params);
|
||||
|
||||
Object eval(byte[] script, List<byte[]> keys, List<byte[]> args);
|
||||
|
||||
Object eval(byte[] script);
|
||||
|
||||
Object evalsha(byte[] script);
|
||||
|
||||
Object evalsha(byte[] sha1, List<byte[]> keys, List<byte[]> args);
|
||||
|
||||
Object evalsha(byte[] sha1, int keyCount, byte[]... params);
|
||||
|
||||
// TODO: should be Boolean, add singular version
|
||||
List<Long> scriptExists(byte[]... sha1);
|
||||
|
||||
byte[] scriptLoad(byte[] script);
|
||||
|
||||
String scriptFlush();
|
||||
|
||||
String scriptKill();
|
||||
}
|
||||
@@ -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, MultiKeyCommands, JedisBasicCommands {
|
||||
public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommands, AdvancedJedisCommands, ScriptingCommands {
|
||||
public Jedis(final String host) {
|
||||
super(host);
|
||||
}
|
||||
@@ -2719,6 +2719,29 @@ public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommand
|
||||
return getEvalResult();
|
||||
}
|
||||
|
||||
public void subscribe(final JedisPubSub jedisPubSub,
|
||||
final String... channels) {
|
||||
client.setTimeoutInfinite();
|
||||
jedisPubSub.proceed(client, channels);
|
||||
client.rollbackTimeout();
|
||||
}
|
||||
|
||||
public Long publish(final String channel, final String message) {
|
||||
checkIsInMulti();
|
||||
connect();
|
||||
client.publish(channel, message);
|
||||
return client.getIntegerReply();
|
||||
}
|
||||
|
||||
public void psubscribe(final JedisPubSub jedisPubSub,
|
||||
final String... patterns) {
|
||||
checkIsInMulti();
|
||||
connect();
|
||||
client.setTimeoutInfinite();
|
||||
jedisPubSub.proceedWithPatterns(client, patterns);
|
||||
client.rollbackTimeout();
|
||||
}
|
||||
|
||||
private String[] getParams(List<String> keys, List<String> args) {
|
||||
int keyCount = keys.size();
|
||||
int argCount = args.size();
|
||||
|
||||
@@ -49,6 +49,8 @@ public interface MultiKeyBinaryCommands {
|
||||
|
||||
String watch(byte[]... keys);
|
||||
|
||||
String unwatch();
|
||||
|
||||
Long zinterstore(byte[] dstkey, byte[]... sets);
|
||||
|
||||
Long zinterstore(byte[] dstkey, ZParams params, byte[]... sets);
|
||||
@@ -61,5 +63,9 @@ public interface MultiKeyBinaryCommands {
|
||||
|
||||
Long publish(byte[] channel, byte[] message);
|
||||
|
||||
void subscribe(BinaryJedisPubSub jedisPubSub, byte[]... channels);
|
||||
|
||||
void psubscribe(BinaryJedisPubSub jedisPubSub, byte[]... patterns);
|
||||
|
||||
byte[] randomBinaryKey();
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ public interface MultiKeyCommands {
|
||||
|
||||
String watch(String... keys);
|
||||
|
||||
String unwatch();
|
||||
|
||||
Long zinterstore(String dstkey, String... sets);
|
||||
|
||||
Long zinterstore(String dstkey, ZParams params, String... sets);
|
||||
@@ -61,5 +63,9 @@ public interface MultiKeyCommands {
|
||||
|
||||
Long publish(String channel, String message);
|
||||
|
||||
void subscribe(JedisPubSub jedisPubSub, String... channels);
|
||||
|
||||
void psubscribe(JedisPubSub jedisPubSub, String... patterns);
|
||||
|
||||
String randomKey();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
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);
|
||||
|
||||
public interface ScriptingCommands {
|
||||
Object eval(String script, int keyCount, String... params);
|
||||
|
||||
Object eval(String script, List<String> keys, List<String> args);
|
||||
@@ -27,14 +20,4 @@ public interface JedisBasicCommands {
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user