From 1d03085a8158ca38d792b8049977b8bc8ea92ebc Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Thu, 21 Jun 2012 17:11:46 +0300 Subject: [PATCH] add native execute for JedisConnection --- .../DefaultStringRedisConnection.java | 9 + .../data/redis/connection/RedisCommands.java | 12 + .../connection/StringRedisConnection.java | 2 + .../connection/jedis/JedisConnection.java | 319 ++++++++++-------- .../AbstractConnectionIntegrationTests.java | 18 +- 5 files changed, 213 insertions(+), 147 deletions(-) diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java index 97012ddaa..9714e51c2 100644 --- a/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java @@ -1152,4 +1152,13 @@ public class DefaultStringRedisConnection implements StringRedisConnection { public void openPipeline() { delegate.openPipeline(); } + + + public Object execute(String command, byte[]... args) { + return delegate.execute(command, args); + } + + public Object execute(String command, String... args) { + return execute(command, serializeMulti(args)); + } } \ No newline at end of file diff --git a/src/main/java/org/springframework/data/redis/connection/RedisCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisCommands.java index 507d6faee..ff3ff20c7 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisCommands.java @@ -25,4 +25,16 @@ package org.springframework.data.redis.connection; public interface RedisCommands extends RedisKeyCommands, RedisStringCommands, RedisListCommands, RedisSetCommands, RedisZSetCommands, RedisHashCommands, RedisTxCommands, RedisPubSubCommands, RedisConnectionCommands, RedisServerCommands { + + + /** + * 'Native' or 'raw' execution of the given command along-side the given arguments. + * The command is executed as is, with as little 'interpretation' as possible - it is up to the caller + * to take care of any processing of arguments or the result. + * + * @param command Command to execute + * @param args Possible command arguments (may be null) + * @return execution result. + */ + Object execute(String command, byte[]... args); } \ No newline at end of file diff --git a/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java index a3edf9984..4d92b09f7 100644 --- a/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java @@ -42,6 +42,8 @@ public interface StringRedisConnection extends RedisConnection { String getValueAsString(); } + Object execute(String command, String... args); + Boolean exists(String key); Long del(String... keys); diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java index 4d45a535c..2ad170877 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java @@ -17,6 +17,7 @@ package org.springframework.data.redis.connection.jedis; import java.io.IOException; import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -32,14 +33,19 @@ import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisSubscribedConnectionException; import org.springframework.data.redis.connection.SortParameters; import org.springframework.data.redis.connection.Subscription; +import org.springframework.util.Assert; import org.springframework.util.ReflectionUtils; import redis.clients.jedis.BinaryJedis; import redis.clients.jedis.BinaryJedisPubSub; import redis.clients.jedis.BinaryTransaction; +import redis.clients.jedis.Builder; import redis.clients.jedis.Client; +import redis.clients.jedis.Connection; import redis.clients.jedis.Jedis; import redis.clients.jedis.Pipeline; +import redis.clients.jedis.Protocol.Command; +import redis.clients.jedis.Queable; import redis.clients.jedis.SortingParams; import redis.clients.jedis.Transaction; import redis.clients.jedis.ZParams; @@ -55,10 +61,17 @@ import redis.clients.util.Pool; public class JedisConnection implements RedisConnection { private static final Field CLIENT_FIELD; + private static final Method SEND_COMMAND; + private static final Method GET_RESPONSE; static { CLIENT_FIELD = ReflectionUtils.findField(BinaryJedis.class, "client", Client.class); ReflectionUtils.makeAccessible(CLIENT_FIELD); + SEND_COMMAND = ReflectionUtils.findMethod(Connection.class, "sendCommand", + new Class[] { Command.class, byte[][].class }); + ReflectionUtils.makeAccessible(SEND_COMMAND); + GET_RESPONSE = ReflectionUtils.findMethod(Queable.class, "getResponse", Builder.class); + ReflectionUtils.makeAccessible(GET_RESPONSE); } private final Jedis jedis; @@ -119,7 +132,34 @@ public class JedisConnection implements RedisConnection { return new RedisSystemException("Unknown jedis exception", ex); } - + public Object execute(String command, byte[]... args) { + Assert.hasText(command, "a valid command needs to be specified"); + List mArgs = new ArrayList(); + if (args == null) { + mArgs.add(new byte[0]); + } + else { + Collections.addAll(mArgs, args); + } + + Object result = ReflectionUtils.invokeMethod(SEND_COMMAND, client, + Command.valueOf(command.trim().toUpperCase()), mArgs.toArray(new byte[mArgs.size()][])); + if (isQueueing() || isPipelined()) { + Object target = (isPipelined() ? pipeline : transaction); + ReflectionUtils.invokeMethod(GET_RESPONSE, target, new Builder() { + public Object build(Object data) { + return data; + } + + public String toString() { + return "Object"; + } + }); + } + + return result; + } + public void close() throws DataAccessException { // return the connection to the pool try { @@ -158,12 +198,12 @@ public class JedisConnection implements RedisConnection { } } - + public Jedis getNativeConnection() { return jedis; } - + public boolean isClosed() { try { return !jedis.isConnected(); @@ -172,17 +212,17 @@ public class JedisConnection implements RedisConnection { } } - + public boolean isQueueing() { return client.isInMulti(); } - + public boolean isPipelined() { return (pipeline != null); } - + public void openPipeline() { if (pipeline == null) { pipeline = jedis.pipelined(); @@ -190,7 +230,6 @@ public class JedisConnection implements RedisConnection { } @SuppressWarnings("unchecked") - public List closePipeline() { if (pipeline != null) { List execute = pipeline.syncAndReturnAll(); @@ -201,7 +240,7 @@ public class JedisConnection implements RedisConnection { return Collections.emptyList(); } - + public List sort(byte[] key, SortParameters params) { SortingParams sortParams = JedisUtils.convertSortParams(params); @@ -233,7 +272,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long sort(byte[] key, SortParameters params, byte[] sortKey) { SortingParams sortParams = JedisUtils.convertSortParams(params); @@ -265,14 +304,14 @@ public class JedisConnection implements RedisConnection { } } - + public Long dbSize() { try { if (isQueueing()) { - throw new UnsupportedOperationException(); + transaction.dbSize(); } if (isPipelined()) { - throw new UnsupportedOperationException(); + pipeline.dbSize(); } return jedis.dbSize(); } catch (Exception ex) { @@ -281,14 +320,14 @@ public class JedisConnection implements RedisConnection { } - + public void flushDb() { try { if (isQueueing()) { - throw new UnsupportedOperationException(); + transaction.flushDB(); } if (isPipelined()) { - throw new UnsupportedOperationException(); + pipeline.flushDB(); } jedis.flushDB(); } catch (Exception ex) { @@ -296,14 +335,14 @@ public class JedisConnection implements RedisConnection { } } - + public void flushAll() { try { if (isQueueing()) { - throw new UnsupportedOperationException(); + transaction.flushAll(); } if (isPipelined()) { - throw new UnsupportedOperationException(); + pipeline.flushAll(); } jedis.flushAll(); } catch (Exception ex) { @@ -311,7 +350,7 @@ public class JedisConnection implements RedisConnection { } } - + public void bgSave() { try { if (isQueueing()) { @@ -327,7 +366,7 @@ public class JedisConnection implements RedisConnection { } } - + public void bgWriteAof() { try { if (isQueueing()) { @@ -343,7 +382,7 @@ public class JedisConnection implements RedisConnection { } } - + public void save() { try { if (isQueueing()) { @@ -359,7 +398,7 @@ public class JedisConnection implements RedisConnection { } } - + public List getConfig(String param) { try { if (isQueueing()) { @@ -375,7 +414,7 @@ public class JedisConnection implements RedisConnection { } } - + public Properties info() { try { if (isQueueing()) { @@ -390,7 +429,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long lastSave() { try { if (isQueueing()) { @@ -406,7 +445,7 @@ public class JedisConnection implements RedisConnection { } } - + public void setConfig(String param, String value) { try { if (isQueueing()) { @@ -423,7 +462,7 @@ public class JedisConnection implements RedisConnection { } - + public void resetConfigStats() { try { if (isQueueing()) { @@ -439,7 +478,7 @@ public class JedisConnection implements RedisConnection { } } - + public void shutdown() { try { if (isQueueing()) { @@ -454,7 +493,7 @@ public class JedisConnection implements RedisConnection { } } - + public byte[] echo(byte[] message) { try { if (isQueueing()) { @@ -470,7 +509,7 @@ public class JedisConnection implements RedisConnection { } } - + public String ping() { try { if (isQueueing()) { @@ -485,7 +524,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long del(byte[]... keys) { try { if (isQueueing()) { @@ -502,7 +541,7 @@ public class JedisConnection implements RedisConnection { } } - + public void discard() { try { client.discard(); @@ -511,7 +550,7 @@ public class JedisConnection implements RedisConnection { } } - + public List exec() { try { if (isPipelined()) { @@ -524,7 +563,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean exists(byte[] key) { try { if (isQueueing()) { @@ -541,7 +580,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean expire(byte[] key, long seconds) { try { if (isQueueing()) { @@ -558,7 +597,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean expireAt(byte[] key, long unixTime) { try { if (isQueueing()) { @@ -575,7 +614,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set keys(byte[] pattern) { try { if (isQueueing()) { @@ -592,7 +631,7 @@ public class JedisConnection implements RedisConnection { } } - + public void multi() { if (isQueueing()) { return; @@ -608,7 +647,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean persist(byte[] key) { try { if (isQueueing()) { @@ -625,7 +664,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean move(byte[] key, int dbIndex) { try { if (isQueueing()) { @@ -642,7 +681,7 @@ public class JedisConnection implements RedisConnection { } } - + public byte[] randomKey() { try { if (isQueueing()) { @@ -657,7 +696,7 @@ public class JedisConnection implements RedisConnection { } } - + public void rename(byte[] oldName, byte[] newName) { try { if (isQueueing()) { @@ -674,7 +713,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean renameNX(byte[] oldName, byte[] newName) { try { if (isQueueing()) { @@ -691,7 +730,7 @@ public class JedisConnection implements RedisConnection { } } - + public void select(int dbIndex) { try { if (isQueueing()) { @@ -706,7 +745,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long ttl(byte[] key) { try { if (isQueueing()) { @@ -723,7 +762,7 @@ public class JedisConnection implements RedisConnection { } } - + public DataType type(byte[] key) { try { if (isQueueing()) { @@ -740,7 +779,7 @@ public class JedisConnection implements RedisConnection { } } - + public void unwatch() { try { jedis.unwatch(); @@ -749,7 +788,7 @@ public class JedisConnection implements RedisConnection { } } - + public void watch(byte[]... keys) { if (isQueueing()) { throw new UnsupportedOperationException(); @@ -772,7 +811,7 @@ public class JedisConnection implements RedisConnection { // String commands // - + public byte[] get(byte[] key) { try { if (isQueueing()) { @@ -790,7 +829,7 @@ public class JedisConnection implements RedisConnection { } } - + public void set(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -808,7 +847,7 @@ public class JedisConnection implements RedisConnection { } - + public byte[] getSet(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -825,7 +864,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long append(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -842,7 +881,7 @@ public class JedisConnection implements RedisConnection { } } - + public List mGet(byte[]... keys) { try { if (isQueueing()) { @@ -859,7 +898,7 @@ public class JedisConnection implements RedisConnection { } } - + public void mSet(Map tuples) { try { if (isQueueing()) { @@ -876,7 +915,7 @@ public class JedisConnection implements RedisConnection { } } - + public void mSetNX(Map tuples) { try { if (isQueueing()) { @@ -893,7 +932,7 @@ public class JedisConnection implements RedisConnection { } } - + public void setEx(byte[] key, long time, byte[] value) { try { if (isQueueing()) { @@ -910,7 +949,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean setNX(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -927,7 +966,7 @@ public class JedisConnection implements RedisConnection { } } - + public byte[] getRange(byte[] key, long start, long end) { try { if (isQueueing()) { @@ -944,7 +983,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long decr(byte[] key) { try { if (isQueueing()) { @@ -961,7 +1000,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long decrBy(byte[] key, long value) { try { if (isQueueing()) { @@ -978,7 +1017,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long incr(byte[] key) { try { if (isQueueing()) { @@ -995,7 +1034,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long incrBy(byte[] key, long value) { try { if (isQueueing()) { @@ -1012,7 +1051,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean getBit(byte[] key, long offset) { try { if (isQueueing()) { @@ -1025,7 +1064,7 @@ public class JedisConnection implements RedisConnection { Object getBit = jedis.getbit(key, offset); // Jedis 2.0 if (getBit instanceof Long) { - return (((Long)getBit) == 0 ? Boolean.FALSE : Boolean.TRUE); + return (((Long) getBit) == 0 ? Boolean.FALSE : Boolean.TRUE); } // Jedis 2.1 return ((Boolean) getBit); @@ -1034,7 +1073,7 @@ public class JedisConnection implements RedisConnection { } } - + public void setBit(byte[] key, long offset, boolean value) { try { if (isQueueing()) { @@ -1049,7 +1088,7 @@ public class JedisConnection implements RedisConnection { } } - + public void setRange(byte[] key, byte[] value, long start) { try { if (isQueueing()) { @@ -1064,7 +1103,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long strLen(byte[] key) { try { if (isQueueing()) { @@ -1085,7 +1124,7 @@ public class JedisConnection implements RedisConnection { // List commands // - + public Long lPush(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -1102,7 +1141,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long rPush(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -1119,7 +1158,7 @@ public class JedisConnection implements RedisConnection { } } - + public List bLPop(int timeout, byte[]... keys) { try { if (isQueueing()) { @@ -1136,7 +1175,7 @@ public class JedisConnection implements RedisConnection { } } - + public List bRPop(int timeout, byte[]... keys) { try { if (isQueueing()) { @@ -1152,7 +1191,7 @@ public class JedisConnection implements RedisConnection { } } - + public byte[] lIndex(byte[] key, long index) { try { if (isQueueing()) { @@ -1169,7 +1208,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long lInsert(byte[] key, Position where, byte[] pivot, byte[] value) { try { if (isQueueing()) { @@ -1186,7 +1225,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long lLen(byte[] key) { try { if (isQueueing()) { @@ -1203,7 +1242,7 @@ public class JedisConnection implements RedisConnection { } } - + public byte[] lPop(byte[] key) { try { if (isQueueing()) { @@ -1220,7 +1259,7 @@ public class JedisConnection implements RedisConnection { } } - + public List lRange(byte[] key, long start, long end) { try { if (isQueueing()) { @@ -1237,7 +1276,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long lRem(byte[] key, long count, byte[] value) { try { if (isQueueing()) { @@ -1254,7 +1293,7 @@ public class JedisConnection implements RedisConnection { } } - + public void lSet(byte[] key, long index, byte[] value) { try { if (isQueueing()) { @@ -1271,7 +1310,7 @@ public class JedisConnection implements RedisConnection { } } - + public void lTrim(byte[] key, long start, long end) { try { if (isQueueing()) { @@ -1288,7 +1327,7 @@ public class JedisConnection implements RedisConnection { } } - + public byte[] rPop(byte[] key) { try { if (isQueueing()) { @@ -1305,7 +1344,7 @@ public class JedisConnection implements RedisConnection { } } - + public byte[] rPopLPush(byte[] srcKey, byte[] dstKey) { try { if (isQueueing()) { @@ -1322,7 +1361,7 @@ public class JedisConnection implements RedisConnection { } } - + public byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey) { try { if (isQueueing()) { @@ -1339,7 +1378,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long lPushX(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -1356,7 +1395,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long rPushX(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -1378,7 +1417,7 @@ public class JedisConnection implements RedisConnection { // Set commands // - + public Boolean sAdd(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -1395,7 +1434,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long sCard(byte[] key) { try { if (isQueueing()) { @@ -1412,7 +1451,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set sDiff(byte[]... keys) { try { if (isQueueing()) { @@ -1429,7 +1468,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long sDiffStore(byte[] destKey, byte[]... keys) { try { if (isQueueing()) { @@ -1446,7 +1485,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set sInter(byte[]... keys) { try { if (isQueueing()) { @@ -1463,7 +1502,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long sInterStore(byte[] destKey, byte[]... keys) { try { if (isQueueing()) { @@ -1480,7 +1519,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean sIsMember(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -1497,7 +1536,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set sMembers(byte[] key) { try { if (isQueueing()) { @@ -1514,7 +1553,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean sMove(byte[] srcKey, byte[] destKey, byte[] value) { try { if (isQueueing()) { @@ -1531,7 +1570,7 @@ public class JedisConnection implements RedisConnection { } } - + public byte[] sPop(byte[] key) { try { if (isQueueing()) { @@ -1548,7 +1587,7 @@ public class JedisConnection implements RedisConnection { } } - + public byte[] sRandMember(byte[] key) { try { if (isQueueing()) { @@ -1565,7 +1604,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean sRem(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -1582,7 +1621,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set sUnion(byte[]... keys) { try { if (isQueueing()) { @@ -1599,7 +1638,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long sUnionStore(byte[] destKey, byte[]... keys) { try { if (isQueueing()) { @@ -1620,7 +1659,7 @@ public class JedisConnection implements RedisConnection { // ZSet commands // - + public Boolean zAdd(byte[] key, double score, byte[] value) { try { if (isQueueing()) { @@ -1637,7 +1676,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long zCard(byte[] key) { try { if (isQueueing()) { @@ -1654,7 +1693,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long zCount(byte[] key, double min, double max) { try { if (isQueueing()) { @@ -1671,7 +1710,7 @@ public class JedisConnection implements RedisConnection { } } - + public Double zIncrBy(byte[] key, double increment, byte[] value) { try { if (isQueueing()) { @@ -1688,7 +1727,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long zInterStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) { try { ZParams zparams = new ZParams().weights(weights).aggregate( @@ -1708,7 +1747,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long zInterStore(byte[] destKey, byte[]... sets) { try { if (isQueueing()) { @@ -1725,7 +1764,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set zRange(byte[] key, long start, long end) { try { if (isQueueing()) { @@ -1742,7 +1781,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set zRangeWithScores(byte[] key, long start, long end) { try { if (isQueueing()) { @@ -1759,7 +1798,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set zRangeByScore(byte[] key, double min, double max) { try { if (isQueueing()) { @@ -1776,7 +1815,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set zRangeByScoreWithScores(byte[] key, double min, double max) { try { if (isQueueing()) { @@ -1793,7 +1832,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set zRevRangeWithScores(byte[] key, long start, long end) { try { if (isQueueing()) { @@ -1810,7 +1849,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set zRangeByScore(byte[] key, double min, double max, long offset, long count) { try { if (isQueueing()) { @@ -1827,7 +1866,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set zRangeByScoreWithScores(byte[] key, double min, double max, long offset, long count) { try { if (isQueueing()) { @@ -1844,7 +1883,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set zRevRangeByScore(byte[] key, double min, double max, long offset, long count) { try { if (isQueueing()) { @@ -1859,7 +1898,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set zRevRangeByScore(byte[] key, double min, double max) { try { if (isQueueing()) { @@ -1874,7 +1913,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set zRevRangeByScoreWithScores(byte[] key, double min, double max, long offset, long count) { try { if (isQueueing()) { @@ -1890,7 +1929,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set zRevRangeByScoreWithScores(byte[] key, double min, double max) { try { if (isQueueing()) { @@ -1905,7 +1944,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long zRank(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -1922,7 +1961,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean zRem(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -1939,7 +1978,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long zRemRange(byte[] key, long start, long end) { try { if (isQueueing()) { @@ -1956,7 +1995,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long zRemRangeByScore(byte[] key, double min, double max) { try { if (isQueueing()) { @@ -1973,7 +2012,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set zRevRange(byte[] key, long start, long end) { try { if (isQueueing()) { @@ -1990,7 +2029,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long zRevRank(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -2007,7 +2046,7 @@ public class JedisConnection implements RedisConnection { } } - + public Double zScore(byte[] key, byte[] value) { try { if (isQueueing()) { @@ -2024,7 +2063,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long zUnionStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) { try { ZParams zparams = new ZParams().weights(weights).aggregate( @@ -2044,7 +2083,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long zUnionStore(byte[] destKey, byte[]... sets) { try { if (isQueueing()) { @@ -2065,7 +2104,7 @@ public class JedisConnection implements RedisConnection { // Hash commands // - + public Boolean hSet(byte[] key, byte[] field, byte[] value) { try { if (isQueueing()) { @@ -2082,7 +2121,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean hSetNX(byte[] key, byte[] field, byte[] value) { try { if (isQueueing()) { @@ -2099,7 +2138,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean hDel(byte[] key, byte[] field) { try { if (isQueueing()) { @@ -2116,7 +2155,7 @@ public class JedisConnection implements RedisConnection { } } - + public Boolean hExists(byte[] key, byte[] field) { try { if (isQueueing()) { @@ -2133,7 +2172,7 @@ public class JedisConnection implements RedisConnection { } } - + public byte[] hGet(byte[] key, byte[] field) { try { if (isQueueing()) { @@ -2150,7 +2189,7 @@ public class JedisConnection implements RedisConnection { } } - + public Map hGetAll(byte[] key) { try { if (isQueueing()) { @@ -2167,7 +2206,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long hIncrBy(byte[] key, byte[] field, long delta) { try { if (isQueueing()) { @@ -2184,7 +2223,7 @@ public class JedisConnection implements RedisConnection { } } - + public Set hKeys(byte[] key) { try { if (isQueueing()) { @@ -2201,7 +2240,7 @@ public class JedisConnection implements RedisConnection { } } - + public Long hLen(byte[] key) { try { if (isQueueing()) { @@ -2218,7 +2257,7 @@ public class JedisConnection implements RedisConnection { } } - + public List hMGet(byte[] key, byte[]... fields) { try { if (isQueueing()) { @@ -2235,7 +2274,7 @@ public class JedisConnection implements RedisConnection { } } - + public void hMSet(byte[] key, Map tuple) { try { if (isQueueing()) { @@ -2252,7 +2291,7 @@ public class JedisConnection implements RedisConnection { } } - + public List hVals(byte[] key) { try { if (isQueueing()) { @@ -2273,7 +2312,7 @@ public class JedisConnection implements RedisConnection { // // Pub/Sub functionality // - + public Long publish(byte[] channel, byte[] message) { try { if (isQueueing()) { @@ -2289,17 +2328,17 @@ public class JedisConnection implements RedisConnection { } } - + public Subscription getSubscription() { return subscription; } - + public boolean isSubscribed() { return (subscription != null && subscription.isAlive()); } - + public void pSubscribe(MessageListener listener, byte[]... patterns) { if (isSubscribed()) { throw new RedisSubscribedConnectionException( @@ -2324,7 +2363,7 @@ public class JedisConnection implements RedisConnection { } } - + public void subscribe(MessageListener listener, byte[]... channels) { if (isSubscribed()) { throw new RedisSubscribedConnectionException( diff --git a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java index 4b4d3276f..6dc0354a9 100644 --- a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java @@ -16,7 +16,12 @@ package org.springframework.data.redis.connection; -import static org.junit.Assert.*; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.List; @@ -34,12 +39,6 @@ import org.springframework.dao.DataAccessException; import org.springframework.data.redis.Address; import org.springframework.data.redis.ConnectionFactoryTracker; import org.springframework.data.redis.Person; -import org.springframework.data.redis.connection.DefaultStringRedisConnection; -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.data.redis.connection.RedisConnection; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.connection.StringRedisConnection; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer; import org.springframework.data.redis.serializer.RedisSerializer; @@ -333,4 +332,9 @@ public abstract class AbstractConnectionIntegrationTests { th.start(); connection.pSubscribe(listener, expectedPattern); } + + @Test + public void testExecuteNative() throws Exception { + connection.execute("ZADD", getClass() + "#testExecuteNative", "0.9090", "item"); + } } \ No newline at end of file