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 223f31460..37bab44fb 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 @@ -314,7 +314,9 @@ public class JedisConnection implements RedisConnection { } private void pipeline(FutureResult> result) { - pipelinedResults.add(result); + if(!isQueueing()) { + pipelinedResults.add(result); + } } public List sort(byte[] key, SortParameters params) { @@ -322,16 +324,6 @@ public class JedisConnection implements RedisConnection { SortingParams sortParams = JedisConverters.toSortingParams(params); try { - if (isQueueing()) { - if (sortParams != null) { - transaction.sort(key, sortParams); - } - else { - transaction.sort(key); - } - - return null; - } if (isPipelined()) { if (sortParams != null) { pipeline(new JedisResult(pipeline.sort(key, sortParams), JedisConverters.stringListToByteList())); @@ -344,6 +336,16 @@ public class JedisConnection implements RedisConnection { return null; } + if (isQueueing()) { + if (sortParams != null) { + transaction.sort(key, sortParams); + } + else { + transaction.sort(key); + } + + return null; + } return (sortParams != null ? jedis.sort(key, sortParams) : jedis.sort(key)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -356,16 +358,6 @@ public class JedisConnection implements RedisConnection { SortingParams sortParams = JedisConverters.toSortingParams(params); try { - if (isQueueing()) { - if (sortParams != null) { - transaction.sort(key, sortParams, storeKey); - } - else { - transaction.sort(key, storeKey); - } - - return null; - } if (isPipelined()) { if (sortParams != null) { pipeline(new JedisResult(pipeline.sort(key, sortParams, storeKey))); @@ -376,6 +368,16 @@ public class JedisConnection implements RedisConnection { return null; } + if (isQueueing()) { + if (sortParams != null) { + transaction.sort(key, sortParams, storeKey); + } + else { + transaction.sort(key, storeKey); + } + + return null; + } return (sortParams != null ? jedis.sort(key, sortParams, storeKey) : jedis.sort(key, storeKey)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -385,14 +387,14 @@ public class JedisConnection implements RedisConnection { public Long dbSize() { try { - if (isQueueing()) { - transaction.dbSize(); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.dbSize())); return null; } + if (isQueueing()) { + transaction.dbSize(); + return null; + } return jedis.dbSize(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -403,14 +405,14 @@ public class JedisConnection implements RedisConnection { public void flushDb() { try { - if (isQueueing()) { - transaction.flushDB(); - return; - } if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.flushDB())); return; } + if (isQueueing()) { + transaction.flushDB(); + return; + } jedis.flushDB(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -420,14 +422,14 @@ public class JedisConnection implements RedisConnection { public void flushAll() { try { - if (isQueueing()) { - transaction.flushAll(); - return; - } if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.flushAll())); return; } + if (isQueueing()) { + transaction.flushAll(); + return; + } jedis.flushAll(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -436,14 +438,18 @@ public class JedisConnection implements RedisConnection { public void bgSave() { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } try { if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.bgsave())); return; } + } catch (Exception ex) { + throw convertJedisAccessException(ex); + } + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + try { jedis.bgsave(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -452,14 +458,18 @@ public class JedisConnection implements RedisConnection { public void bgWriteAof() { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } try { if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.bgrewriteaof())); return; } + } catch (Exception ex) { + throw convertJedisAccessException(ex); + } + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + try { jedis.bgrewriteaof(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -468,14 +478,18 @@ public class JedisConnection implements RedisConnection { public void save() { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } try { if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.save())); return; } + } catch (Exception ex) { + throw convertJedisAccessException(ex); + } + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + try { jedis.save(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -484,14 +498,18 @@ public class JedisConnection implements RedisConnection { public List getConfig(String param) { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } try { if (isPipelined()) { pipeline(new JedisResult(pipeline.configGet(param))); return null; } + } catch (Exception ex) { + throw convertJedisAccessException(ex); + } + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + try { return jedis.configGet(param); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -520,14 +538,18 @@ public class JedisConnection implements RedisConnection { public Long lastSave() { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } try { if (isPipelined()) { pipeline(new JedisResult(pipeline.lastsave())); return null; } + } catch (Exception ex) { + throw convertJedisAccessException(ex); + } + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + try { return jedis.lastsave(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -536,14 +558,18 @@ public class JedisConnection implements RedisConnection { public void setConfig(String param, String value) { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } try { if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.configSet(param, value))); return; } + } catch (Exception ex) { + throw convertJedisAccessException(ex); + } + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + try { jedis.configSet(param, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -553,14 +579,18 @@ public class JedisConnection implements RedisConnection { public void resetConfigStats() { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } try { if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.configResetStat())); return; } + } catch (Exception ex) { + throw convertJedisAccessException(ex); + } + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + try { jedis.configResetStat(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -584,14 +614,18 @@ public class JedisConnection implements RedisConnection { public byte[] echo(byte[] message) { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } try { if (isPipelined()) { pipeline(new JedisResult(pipeline.echo(message),JedisConverters.stringToBytes())); return null; } + } catch (Exception ex) { + throw convertJedisAccessException(ex); + } + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + try { return jedis.echo(message); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -616,14 +650,14 @@ public class JedisConnection implements RedisConnection { public Long del(byte[]... keys) { try { - if (isQueueing()) { - transaction.del(keys); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.del(keys))); return null; } + if (isQueueing()) { + transaction.del(keys); + return null; + } return jedis.del(keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -659,14 +693,14 @@ public class JedisConnection implements RedisConnection { public Boolean exists(byte[] key) { try { - if (isQueueing()) { - transaction.exists(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.exists(key))); return null; } + if (isQueueing()) { + transaction.exists(key); + return null; + } return jedis.exists(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -676,14 +710,14 @@ public class JedisConnection implements RedisConnection { public Boolean expire(byte[] key, long seconds) { try { - if (isQueueing()) { - transaction.expire(key, (int) seconds); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.expire(key, (int) seconds), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.expire(key, (int) seconds); + return null; + } return JedisConverters.toBoolean(jedis.expire(key, (int) seconds)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -693,14 +727,14 @@ public class JedisConnection implements RedisConnection { public Boolean expireAt(byte[] key, long unixTime) { try { - if (isQueueing()) { - transaction.expireAt(key, unixTime); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.expireAt(key, unixTime), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.expireAt(key, unixTime); + return null; + } return JedisConverters.toBoolean(jedis.expireAt(key, unixTime)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -710,14 +744,14 @@ public class JedisConnection implements RedisConnection { public Set keys(byte[] pattern) { try { - if (isQueueing()) { - transaction.keys(pattern); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.keys(pattern), JedisConverters.stringSetToByteSet())); return null; } + if (isQueueing()) { + transaction.keys(pattern); + return null; + } return (jedis.keys(pattern)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -743,14 +777,14 @@ public class JedisConnection implements RedisConnection { public Boolean persist(byte[] key) { try { - if (isQueueing()) { - transaction.persist(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.persist(key), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.persist(key); + return null; + } return JedisConverters.toBoolean(jedis.persist(key)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -760,14 +794,14 @@ public class JedisConnection implements RedisConnection { public Boolean move(byte[] key, int dbIndex) { try { - if (isQueueing()) { - transaction.move(key, dbIndex); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.move(key, dbIndex), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.move(key, dbIndex); + return null; + } return JedisConverters.toBoolean(jedis.move(key, dbIndex)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -792,14 +826,14 @@ public class JedisConnection implements RedisConnection { public void rename(byte[] oldName, byte[] newName) { try { - if (isQueueing()) { - transaction.rename(oldName, newName); - return; - } if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.rename(oldName, newName))); return; } + if (isQueueing()) { + transaction.rename(oldName, newName); + return; + } jedis.rename(oldName, newName); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -809,14 +843,14 @@ public class JedisConnection implements RedisConnection { public Boolean renameNX(byte[] oldName, byte[] newName) { try { - if (isQueueing()) { - transaction.renamenx(oldName, newName); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.renamenx(oldName, newName), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.renamenx(oldName, newName); + return null; + } return JedisConverters.toBoolean(jedis.renamenx(oldName, newName)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -841,14 +875,14 @@ public class JedisConnection implements RedisConnection { public Long ttl(byte[] key) { try { - if (isQueueing()) { - transaction.ttl(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.ttl(key))); return null; } + if (isQueueing()) { + transaction.ttl(key); + return null; + } return jedis.ttl(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -877,14 +911,14 @@ public class JedisConnection implements RedisConnection { public DataType type(byte[] key) { try { - if (isQueueing()) { - transaction.type(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.type(key), JedisConverters.stringToDataType())); return null; } + if (isQueueing()) { + transaction.type(key); + return null; + } return JedisConverters.toDataType(jedis.type(key)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -926,14 +960,14 @@ public class JedisConnection implements RedisConnection { public byte[] get(byte[] key) { try { - if (isQueueing()) { - transaction.get(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.get(key))); return null; } + if (isQueueing()) { + transaction.get(key); + return null; + } return jedis.get(key); } catch (Exception ex) { @@ -944,14 +978,14 @@ public class JedisConnection implements RedisConnection { public void set(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.set(key, value); - return; - } if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.set(key, value))); return; } + if (isQueueing()) { + transaction.set(key, value); + return; + } jedis.set(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -962,14 +996,14 @@ public class JedisConnection implements RedisConnection { public byte[] getSet(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.getSet(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.getSet(key, value))); return null; } + if (isQueueing()) { + transaction.getSet(key, value); + return null; + } return jedis.getSet(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -979,14 +1013,14 @@ public class JedisConnection implements RedisConnection { public Long append(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.append(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.append(key, value))); return null; } + if (isQueueing()) { + transaction.append(key, value); + return null; + } return jedis.append(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -996,14 +1030,14 @@ public class JedisConnection implements RedisConnection { public List mGet(byte[]... keys) { try { - if (isQueueing()) { - transaction.mget(keys); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.mget(keys), JedisConverters.stringListToByteList())); return null; } + if (isQueueing()) { + transaction.mget(keys); + return null; + } return jedis.mget(keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1013,14 +1047,14 @@ public class JedisConnection implements RedisConnection { public void mSet(Map tuples) { try { - if (isQueueing()) { - transaction.mset(JedisConverters.toByteArrays(tuples)); - return; - } if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.mset(JedisConverters.toByteArrays(tuples)))); return; } + if (isQueueing()) { + transaction.mset(JedisConverters.toByteArrays(tuples)); + return; + } jedis.mset(JedisConverters.toByteArrays(tuples)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1030,14 +1064,14 @@ public class JedisConnection implements RedisConnection { public Boolean mSetNX(Map tuples) { try { - if (isQueueing()) { - transaction.msetnx(JedisConverters.toByteArrays(tuples)); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.msetnx(JedisConverters.toByteArrays(tuples)), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.msetnx(JedisConverters.toByteArrays(tuples)); + return null; + } return JedisConverters.toBoolean(jedis.msetnx(JedisConverters.toByteArrays(tuples))); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1047,14 +1081,14 @@ public class JedisConnection implements RedisConnection { public void setEx(byte[] key, long time, byte[] value) { try { - if (isQueueing()) { - transaction.setex(key, (int) time, value); - return; - } if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.setex(key, (int) time, value))); return; } + if (isQueueing()) { + transaction.setex(key, (int) time, value); + return; + } jedis.setex(key, (int) time, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1064,14 +1098,14 @@ public class JedisConnection implements RedisConnection { public Boolean setNX(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.setnx(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.setnx(key, value), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.setnx(key, value); + return null; + } return JedisConverters.toBoolean(jedis.setnx(key, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1081,14 +1115,14 @@ public class JedisConnection implements RedisConnection { public byte[] getRange(byte[] key, long start, long end) { try { - if (isQueueing()) { - transaction.substr(key, (int) start, (int) end); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.substr(key, (int) start, (int) end), JedisConverters.stringToBytes())); return null; } + if (isQueueing()) { + transaction.substr(key, (int) start, (int) end); + return null; + } return jedis.substr(key, (int) start, (int) end); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1098,14 +1132,14 @@ public class JedisConnection implements RedisConnection { public Long decr(byte[] key) { try { - if (isQueueing()) { - transaction.decr(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.decr(key))); return null; } + if (isQueueing()) { + transaction.decr(key); + return null; + } return jedis.decr(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1115,14 +1149,14 @@ public class JedisConnection implements RedisConnection { public Long decrBy(byte[] key, long value) { try { - if (isQueueing()) { - transaction.decrBy(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.decrBy(key, value))); return null; } + if (isQueueing()) { + transaction.decrBy(key, value); + return null; + } return jedis.decrBy(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1132,14 +1166,14 @@ public class JedisConnection implements RedisConnection { public Long incr(byte[] key) { try { - if (isQueueing()) { - transaction.incr(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.incr(key))); return null; } + if (isQueueing()) { + transaction.incr(key); + return null; + } return jedis.incr(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1149,14 +1183,14 @@ public class JedisConnection implements RedisConnection { public Long incrBy(byte[] key, long value) { try { - if (isQueueing()) { - transaction.incrBy(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.incrBy(key, value))); return null; } + if (isQueueing()) { + transaction.incrBy(key, value); + return null; + } return jedis.incrBy(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1221,14 +1255,14 @@ public class JedisConnection implements RedisConnection { public Long strLen(byte[] key) { try { - if (isQueueing()) { - transaction.strlen(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.strlen(key))); return null; } + if (isQueueing()) { + transaction.strlen(key); + return null; + } return jedis.strlen(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1256,14 +1290,14 @@ public class JedisConnection implements RedisConnection { public Long lPush(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.lpush(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.lpush(key, value))); return null; } + if (isQueueing()) { + transaction.lpush(key, value); + return null; + } return jedis.lpush(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1273,14 +1307,14 @@ public class JedisConnection implements RedisConnection { public Long rPush(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.rpush(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.rpush(key, value))); return null; } + if (isQueueing()) { + transaction.rpush(key, value); + return null; + } return jedis.rpush(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1290,14 +1324,14 @@ public class JedisConnection implements RedisConnection { public List bLPop(int timeout, byte[]... keys) { try { - if (isQueueing()) { - transaction.blpop(bXPopArgs(timeout, keys)); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.blpop(bXPopArgs(timeout, keys)), JedisConverters.stringListToByteList())); return null; } + if (isQueueing()) { + transaction.blpop(bXPopArgs(timeout, keys)); + return null; + } return jedis.blpop(timeout, keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1307,14 +1341,14 @@ public class JedisConnection implements RedisConnection { public List bRPop(int timeout, byte[]... keys) { try { - if (isQueueing()) { - transaction.brpop(bXPopArgs(timeout, keys)); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.brpop(bXPopArgs(timeout, keys)), JedisConverters.stringListToByteList())); return null; } + if (isQueueing()) { + transaction.brpop(bXPopArgs(timeout, keys)); + return null; + } return jedis.brpop(timeout, keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1324,14 +1358,14 @@ public class JedisConnection implements RedisConnection { public byte[] lIndex(byte[] key, long index) { try { - if (isQueueing()) { - transaction.lindex(key, (int) index); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.lindex(key, (int) index), JedisConverters.stringToBytes())); return null; } + if (isQueueing()) { + transaction.lindex(key, (int) index); + return null; + } return jedis.lindex(key, (int) index); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1341,14 +1375,14 @@ public class JedisConnection implements RedisConnection { public Long lInsert(byte[] key, Position where, byte[] pivot, byte[] value) { try { - if (isQueueing()) { - transaction.linsert(key, JedisConverters.toListPosition(where), pivot, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.linsert(key, JedisConverters.toListPosition(where), pivot, value))); return null; } + if (isQueueing()) { + transaction.linsert(key, JedisConverters.toListPosition(where), pivot, value); + return null; + } return jedis.linsert(key, JedisConverters.toListPosition(where), pivot, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1358,14 +1392,14 @@ public class JedisConnection implements RedisConnection { public Long lLen(byte[] key) { try { - if (isQueueing()) { - transaction.llen(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.llen(key))); return null; } + if (isQueueing()) { + transaction.llen(key); + return null; + } return jedis.llen(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1375,14 +1409,14 @@ public class JedisConnection implements RedisConnection { public byte[] lPop(byte[] key) { try { - if (isQueueing()) { - transaction.lpop(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.lpop(key), JedisConverters.stringToBytes())); return null; } + if (isQueueing()) { + transaction.lpop(key); + return null; + } return jedis.lpop(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1392,14 +1426,14 @@ public class JedisConnection implements RedisConnection { public List lRange(byte[] key, long start, long end) { try { - if (isQueueing()) { - transaction.lrange(key, (int) start, (int) end); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.lrange(key, (int) start, (int) end), JedisConverters.stringListToByteList())); return null; } + if (isQueueing()) { + transaction.lrange(key, (int) start, (int) end); + return null; + } return jedis.lrange(key, (int) start, (int) end); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1409,14 +1443,14 @@ public class JedisConnection implements RedisConnection { public Long lRem(byte[] key, long count, byte[] value) { try { - if (isQueueing()) { - transaction.lrem(key, (int) count, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.lrem(key, (int) count, value))); return null; } + if (isQueueing()) { + transaction.lrem(key, (int) count, value); + return null; + } return jedis.lrem(key, (int) count, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1426,14 +1460,14 @@ public class JedisConnection implements RedisConnection { public void lSet(byte[] key, long index, byte[] value) { try { - if (isQueueing()) { - transaction.lset(key, (int) index, value); - return; - } if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.lset(key, (int) index, value))); return; } + if (isQueueing()) { + transaction.lset(key, (int) index, value); + return; + } jedis.lset(key, (int) index, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1443,14 +1477,14 @@ public class JedisConnection implements RedisConnection { public void lTrim(byte[] key, long start, long end) { try { - if (isQueueing()) { - transaction.ltrim(key, (int) start, (int) end); - return; - } if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.ltrim(key, (int) start, (int) end))); return; } + if (isQueueing()) { + transaction.ltrim(key, (int) start, (int) end); + return; + } jedis.ltrim(key, (int) start, (int) end); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1460,14 +1494,14 @@ public class JedisConnection implements RedisConnection { public byte[] rPop(byte[] key) { try { - if (isQueueing()) { - transaction.rpop(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.rpop(key), JedisConverters.stringToBytes())); return null; } + if (isQueueing()) { + transaction.rpop(key); + return null; + } return jedis.rpop(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1477,14 +1511,14 @@ public class JedisConnection implements RedisConnection { public byte[] rPopLPush(byte[] srcKey, byte[] dstKey) { try { - if (isQueueing()) { - transaction.rpoplpush(srcKey, dstKey); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.rpoplpush(srcKey, dstKey), JedisConverters.stringToBytes())); return null; } + if (isQueueing()) { + transaction.rpoplpush(srcKey, dstKey); + return null; + } return jedis.rpoplpush(srcKey, dstKey); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1494,14 +1528,14 @@ public class JedisConnection implements RedisConnection { public byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey) { try { - if (isQueueing()) { - transaction.brpoplpush(srcKey, dstKey, timeout); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.brpoplpush(srcKey, dstKey, timeout), JedisConverters.stringToBytes())); return null; } + if (isQueueing()) { + transaction.brpoplpush(srcKey, dstKey, timeout); + return null; + } return jedis.brpoplpush(srcKey, dstKey, timeout); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1511,14 +1545,14 @@ public class JedisConnection implements RedisConnection { public Long lPushX(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.lpushx(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.lpushx(key, value))); return null; } + if (isQueueing()) { + transaction.lpushx(key, value); + return null; + } return jedis.lpushx(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1528,14 +1562,14 @@ public class JedisConnection implements RedisConnection { public Long rPushX(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.rpushx(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.rpushx(key, value))); return null; } + if (isQueueing()) { + transaction.rpushx(key, value); + return null; + } return jedis.rpushx(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1550,14 +1584,14 @@ public class JedisConnection implements RedisConnection { public Boolean sAdd(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.sadd(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.sadd(key, value), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.sadd(key, value); + return null; + } return JedisConverters.toBoolean(jedis.sadd(key, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1567,14 +1601,14 @@ public class JedisConnection implements RedisConnection { public Long sCard(byte[] key) { try { - if (isQueueing()) { - transaction.scard(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.scard(key))); return null; } + if (isQueueing()) { + transaction.scard(key); + return null; + } return jedis.scard(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1584,14 +1618,14 @@ public class JedisConnection implements RedisConnection { public Set sDiff(byte[]... keys) { try { - if (isQueueing()) { - transaction.sdiff(keys); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.sdiff(keys), JedisConverters.stringSetToByteSet())); return null; } + if (isQueueing()) { + transaction.sdiff(keys); + return null; + } return jedis.sdiff(keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1601,14 +1635,14 @@ public class JedisConnection implements RedisConnection { public Long sDiffStore(byte[] destKey, byte[]... keys) { try { - if (isQueueing()) { - transaction.sdiffstore(destKey, keys); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.sdiffstore(destKey, keys))); return null; } + if (isQueueing()) { + transaction.sdiffstore(destKey, keys); + return null; + } return jedis.sdiffstore(destKey, keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1618,14 +1652,14 @@ public class JedisConnection implements RedisConnection { public Set sInter(byte[]... keys) { try { - if (isQueueing()) { - transaction.sinter(keys); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.sinter(keys), JedisConverters.stringSetToByteSet())); return null; } + if (isQueueing()) { + transaction.sinter(keys); + return null; + } return jedis.sinter(keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1635,14 +1669,14 @@ public class JedisConnection implements RedisConnection { public Long sInterStore(byte[] destKey, byte[]... keys) { try { - if (isQueueing()) { - transaction.sinterstore(destKey, keys); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.sinterstore(destKey, keys))); return null; } + if (isQueueing()) { + transaction.sinterstore(destKey, keys); + return null; + } return jedis.sinterstore(destKey, keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1652,14 +1686,14 @@ public class JedisConnection implements RedisConnection { public Boolean sIsMember(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.sismember(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.sismember(key, value))); return null; } + if (isQueueing()) { + transaction.sismember(key, value); + return null; + } return jedis.sismember(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1669,14 +1703,14 @@ public class JedisConnection implements RedisConnection { public Set sMembers(byte[] key) { try { - if (isQueueing()) { - transaction.smembers(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.smembers(key), JedisConverters.stringSetToByteSet())); return null; } + if (isQueueing()) { + transaction.smembers(key); + return null; + } return jedis.smembers(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1686,14 +1720,14 @@ public class JedisConnection implements RedisConnection { public Boolean sMove(byte[] srcKey, byte[] destKey, byte[] value) { try { - if (isQueueing()) { - transaction.smove(srcKey, destKey, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.smove(srcKey, destKey, value), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.smove(srcKey, destKey, value); + return null; + } return JedisConverters.toBoolean(jedis.smove(srcKey, destKey, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1703,14 +1737,14 @@ public class JedisConnection implements RedisConnection { public byte[] sPop(byte[] key) { try { - if (isQueueing()) { - transaction.spop(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.spop(key), JedisConverters.stringToBytes())); return null; } + if (isQueueing()) { + transaction.spop(key); + return null; + } return jedis.spop(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1720,14 +1754,14 @@ public class JedisConnection implements RedisConnection { public byte[] sRandMember(byte[] key) { try { - if (isQueueing()) { - transaction.srandmember(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.srandmember(key), JedisConverters.stringToBytes())); return null; } + if (isQueueing()) { + transaction.srandmember(key); + return null; + } return jedis.srandmember(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1740,14 +1774,14 @@ public class JedisConnection implements RedisConnection { public Boolean sRem(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.srem(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.srem(key, value), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.srem(key, value); + return null; + } return JedisConverters.toBoolean(jedis.srem(key, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1757,14 +1791,14 @@ public class JedisConnection implements RedisConnection { public Set sUnion(byte[]... keys) { try { - if (isQueueing()) { - transaction.sunion(keys); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.sunion(keys), JedisConverters.stringSetToByteSet())); return null; } + if (isQueueing()) { + transaction.sunion(keys); + return null; + } return jedis.sunion(keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1774,14 +1808,14 @@ public class JedisConnection implements RedisConnection { public Long sUnionStore(byte[] destKey, byte[]... keys) { try { - if (isQueueing()) { - transaction.sunionstore(destKey, keys); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.sunionstore(destKey, keys))); return null; } + if (isQueueing()) { + transaction.sunionstore(destKey, keys); + return null; + } return jedis.sunionstore(destKey, keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1795,14 +1829,14 @@ public class JedisConnection implements RedisConnection { public Boolean zAdd(byte[] key, double score, byte[] value) { try { - if (isQueueing()) { - transaction.zadd(key, score, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zadd(key, score, value), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.zadd(key, score, value); + return null; + } return JedisConverters.toBoolean(jedis.zadd(key, score, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1812,14 +1846,14 @@ public class JedisConnection implements RedisConnection { public Long zCard(byte[] key) { try { - if (isQueueing()) { - transaction.zcard(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zcard(key))); return null; } + if (isQueueing()) { + transaction.zcard(key); + return null; + } return jedis.zcard(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1829,14 +1863,14 @@ public class JedisConnection implements RedisConnection { public Long zCount(byte[] key, double min, double max) { try { - if (isQueueing()) { - transaction.zcount(key, min, max); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zcount(key, min, max))); return null; } + if (isQueueing()) { + transaction.zcount(key, min, max); + return null; + } return jedis.zcount(key, min, max); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1846,14 +1880,14 @@ public class JedisConnection implements RedisConnection { public Double zIncrBy(byte[] key, double increment, byte[] value) { try { - if (isQueueing()) { - transaction.zincrby(key, increment, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zincrby(key, increment, value))); return null; } + if (isQueueing()) { + transaction.zincrby(key, increment, value); + return null; + } return jedis.zincrby(key, increment, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1866,14 +1900,14 @@ public class JedisConnection implements RedisConnection { ZParams zparams = new ZParams().weights(weights).aggregate( redis.clients.jedis.ZParams.Aggregate.valueOf(aggregate.name())); - if (isQueueing()) { - transaction.zinterstore(destKey, zparams, sets); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zinterstore(destKey, zparams, sets))); return null; } + if (isQueueing()) { + transaction.zinterstore(destKey, zparams, sets); + return null; + } return jedis.zinterstore(destKey, zparams, sets); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1883,14 +1917,14 @@ public class JedisConnection implements RedisConnection { public Long zInterStore(byte[] destKey, byte[]... sets) { try { - if (isQueueing()) { - transaction.zinterstore(destKey, sets); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zinterstore(destKey, sets))); return null; } + if (isQueueing()) { + transaction.zinterstore(destKey, sets); + return null; + } return jedis.zinterstore(destKey, sets); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1900,14 +1934,14 @@ public class JedisConnection implements RedisConnection { public Set zRange(byte[] key, long start, long end) { try { - if (isQueueing()) { - transaction.zrange(key, (int) start, (int) end); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zrange(key, (int) start, (int) end), JedisConverters.stringSetToByteSet())); return null; } + if (isQueueing()) { + transaction.zrange(key, (int) start, (int) end); + return null; + } return jedis.zrange(key, (int) start, (int) end); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1917,14 +1951,14 @@ public class JedisConnection implements RedisConnection { public Set zRangeWithScores(byte[] key, long start, long end) { try { - if (isQueueing()) { - transaction.zrangeWithScores(key, (int) start, (int) end); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zrangeWithScores(key, (int) start, (int) end), JedisConverters.tupleSetToTupleSet())); return null; } + if (isQueueing()) { + transaction.zrangeWithScores(key, (int) start, (int) end); + return null; + } return JedisConverters.toTupleSet(jedis.zrangeWithScores(key, (int) start, (int) end)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1934,14 +1968,14 @@ public class JedisConnection implements RedisConnection { public Set zRangeByScore(byte[] key, double min, double max) { try { - if (isQueueing()) { - transaction.zrangeByScore(key, min, max); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zrangeByScore(key, min, max), JedisConverters.stringSetToByteSet())); return null; } + if (isQueueing()) { + transaction.zrangeByScore(key, min, max); + return null; + } return jedis.zrangeByScore(key, min, max); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1951,14 +1985,14 @@ public class JedisConnection implements RedisConnection { public Set zRangeByScoreWithScores(byte[] key, double min, double max) { try { - if (isQueueing()) { - transaction.zrangeByScoreWithScores(key, min, max); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zrangeByScoreWithScores(key, min, max), JedisConverters.tupleSetToTupleSet())); return null; } + if (isQueueing()) { + transaction.zrangeByScoreWithScores(key, min, max); + return null; + } return JedisConverters.toTupleSet(jedis.zrangeByScoreWithScores(key, min, max)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1968,14 +2002,14 @@ public class JedisConnection implements RedisConnection { public Set zRevRangeWithScores(byte[] key, long start, long end) { try { - if (isQueueing()) { - transaction.zrevrangeWithScores(key, (int) start, (int) end); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zrevrangeWithScores(key, (int) start, (int) end), JedisConverters.tupleSetToTupleSet())); return null; } + if (isQueueing()) { + transaction.zrevrangeWithScores(key, (int) start, (int) end); + return null; + } return JedisConverters.toTupleSet(jedis.zrevrangeWithScores(key, (int) start, (int) end)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1985,14 +2019,14 @@ public class JedisConnection implements RedisConnection { public Set zRangeByScore(byte[] key, double min, double max, long offset, long count) { try { - if (isQueueing()) { - transaction.zrangeByScore(key, min, max, (int) offset, (int) count); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zrangeByScore(key, min, max, (int) offset, (int) count), JedisConverters.stringSetToByteSet())); return null; } + if (isQueueing()) { + transaction.zrangeByScore(key, min, max, (int) offset, (int) count); + return null; + } return jedis.zrangeByScore(key, min, max, (int) offset, (int) count); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2002,14 +2036,14 @@ public class JedisConnection implements RedisConnection { public Set zRangeByScoreWithScores(byte[] key, double min, double max, long offset, long count) { try { - if (isQueueing()) { - transaction.zrangeByScoreWithScores(key, min, max, (int) offset, (int) count); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zrangeByScoreWithScores(key, min, max, (int) offset, (int) count), JedisConverters.tupleSetToTupleSet())); return null; } + if (isQueueing()) { + transaction.zrangeByScoreWithScores(key, min, max, (int) offset, (int) count); + return null; + } return JedisConverters.toTupleSet(jedis.zrangeByScoreWithScores(key, min, max, (int) offset, (int) count)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2080,14 +2114,14 @@ public class JedisConnection implements RedisConnection { public Long zRank(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.zrank(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zrank(key, value))); return null; } + if (isQueueing()) { + transaction.zrank(key, value); + return null; + } return jedis.zrank(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2097,14 +2131,14 @@ public class JedisConnection implements RedisConnection { public Boolean zRem(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.zrem(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zrem(key, value), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.zrem(key, value); + return null; + } return JedisConverters.toBoolean(jedis.zrem(key, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2114,14 +2148,14 @@ public class JedisConnection implements RedisConnection { public Long zRemRange(byte[] key, long start, long end) { try { - if (isQueueing()) { - transaction.zremrangeByRank(key, (int) start, (int) end); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zremrangeByRank(key, (int) start, (int) end))); return null; } + if (isQueueing()) { + transaction.zremrangeByRank(key, (int) start, (int) end); + return null; + } return jedis.zremrangeByRank(key, (int) start, (int) end); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2131,14 +2165,14 @@ public class JedisConnection implements RedisConnection { public Long zRemRangeByScore(byte[] key, double min, double max) { try { - if (isQueueing()) { - transaction.zremrangeByScore(key, min, max); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zremrangeByScore(key, min, max))); return null; } + if (isQueueing()) { + transaction.zremrangeByScore(key, min, max); + return null; + } return jedis.zremrangeByScore(key, min, max); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2148,14 +2182,14 @@ public class JedisConnection implements RedisConnection { public Set zRevRange(byte[] key, long start, long end) { try { - if (isQueueing()) { - transaction.zrevrange(key, (int) start, (int) end); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zrevrange(key, (int) start, (int) end), JedisConverters.stringSetToByteSet())); return null; } + if (isQueueing()) { + transaction.zrevrange(key, (int) start, (int) end); + return null; + } return jedis.zrevrange(key, (int) start, (int) end); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2165,14 +2199,14 @@ public class JedisConnection implements RedisConnection { public Long zRevRank(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.zrevrank(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zrevrank(key, value))); return null; } + if (isQueueing()) { + transaction.zrevrank(key, value); + return null; + } return jedis.zrevrank(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2182,14 +2216,14 @@ public class JedisConnection implements RedisConnection { public Double zScore(byte[] key, byte[] value) { try { - if (isQueueing()) { - transaction.zscore(key, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zscore(key, value))); return null; } + if (isQueueing()) { + transaction.zscore(key, value); + return null; + } return jedis.zscore(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2202,14 +2236,14 @@ public class JedisConnection implements RedisConnection { ZParams zparams = new ZParams().weights(weights).aggregate( redis.clients.jedis.ZParams.Aggregate.valueOf(aggregate.name())); - if (isQueueing()) { - transaction.zunionstore(destKey, zparams, sets); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zunionstore(destKey, zparams, sets))); return null; } + if (isQueueing()) { + transaction.zunionstore(destKey, zparams, sets); + return null; + } return jedis.zunionstore(destKey, zparams, sets); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2219,14 +2253,14 @@ public class JedisConnection implements RedisConnection { public Long zUnionStore(byte[] destKey, byte[]... sets) { try { - if (isQueueing()) { - transaction.zunionstore(destKey, sets); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.zunionstore(destKey, sets))); return null; } + if (isQueueing()) { + transaction.zunionstore(destKey, sets); + return null; + } return jedis.zunionstore(destKey, sets); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2240,14 +2274,14 @@ public class JedisConnection implements RedisConnection { public Boolean hSet(byte[] key, byte[] field, byte[] value) { try { - if (isQueueing()) { - transaction.hset(key, field, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.hset(key, field, value), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.hset(key, field, value); + return null; + } return JedisConverters.toBoolean(jedis.hset(key, field, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2257,14 +2291,14 @@ public class JedisConnection implements RedisConnection { public Boolean hSetNX(byte[] key, byte[] field, byte[] value) { try { - if (isQueueing()) { - transaction.hsetnx(key, field, value); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.hsetnx(key, field, value), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.hsetnx(key, field, value); + return null; + } return JedisConverters.toBoolean(jedis.hsetnx(key, field, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2274,14 +2308,14 @@ public class JedisConnection implements RedisConnection { public Boolean hDel(byte[] key, byte[] field) { try { - if (isQueueing()) { - transaction.hdel(key, field); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.hdel(key, field), JedisConverters.longToBoolean())); return null; } + if (isQueueing()) { + transaction.hdel(key, field); + return null; + } return JedisConverters.toBoolean(jedis.hdel(key, field)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2291,14 +2325,14 @@ public class JedisConnection implements RedisConnection { public Boolean hExists(byte[] key, byte[] field) { try { - if (isQueueing()) { - transaction.hexists(key, field); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.hexists(key, field))); return null; } + if (isQueueing()) { + transaction.hexists(key, field); + return null; + } return jedis.hexists(key, field); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2308,14 +2342,14 @@ public class JedisConnection implements RedisConnection { public byte[] hGet(byte[] key, byte[] field) { try { - if (isQueueing()) { - transaction.hget(key, field); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.hget(key, field), JedisConverters.stringToBytes())); return null; } + if (isQueueing()) { + transaction.hget(key, field); + return null; + } return jedis.hget(key, field); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2325,14 +2359,14 @@ public class JedisConnection implements RedisConnection { public Map hGetAll(byte[] key) { try { - if (isQueueing()) { - transaction.hgetAll(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.hgetAll(key), JedisConverters.stringMapToByteMap())); return null; } + if (isQueueing()) { + transaction.hgetAll(key); + return null; + } return jedis.hgetAll(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2342,14 +2376,14 @@ public class JedisConnection implements RedisConnection { public Long hIncrBy(byte[] key, byte[] field, long delta) { try { - if (isQueueing()) { - transaction.hincrBy(key, field, delta); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.hincrBy(key, field, delta))); return null; } + if (isQueueing()) { + transaction.hincrBy(key, field, delta); + return null; + } return jedis.hincrBy(key, field, delta); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2362,14 +2396,14 @@ public class JedisConnection implements RedisConnection { public Set hKeys(byte[] key) { try { - if (isQueueing()) { - transaction.hkeys(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.hkeys(key), JedisConverters.stringSetToByteSet())); return null; } + if (isQueueing()) { + transaction.hkeys(key); + return null; + } return jedis.hkeys(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2379,14 +2413,14 @@ public class JedisConnection implements RedisConnection { public Long hLen(byte[] key) { try { - if (isQueueing()) { - transaction.hlen(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.hlen(key))); return null; } + if (isQueueing()) { + transaction.hlen(key); + return null; + } return jedis.hlen(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2396,14 +2430,14 @@ public class JedisConnection implements RedisConnection { public List hMGet(byte[] key, byte[]... fields) { try { - if (isQueueing()) { - transaction.hmget(key, fields); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.hmget(key, fields), JedisConverters.stringListToByteList())); return null; } + if (isQueueing()) { + transaction.hmget(key, fields); + return null; + } return jedis.hmget(key, fields); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2413,14 +2447,14 @@ public class JedisConnection implements RedisConnection { public void hMSet(byte[] key, Map tuple) { try { - if (isQueueing()) { - transaction.hmset(key, tuple); - return; - } if (isPipelined()) { pipeline(new JedisStatusResult(pipeline.hmset(key, tuple))); return; } + if (isQueueing()) { + transaction.hmset(key, tuple); + return; + } jedis.hmset(key, tuple); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2430,14 +2464,14 @@ public class JedisConnection implements RedisConnection { public List hVals(byte[] key) { try { - if (isQueueing()) { - transaction.hvals(key); - return null; - } if (isPipelined()) { pipeline(new JedisResult(pipeline.hvals(key), JedisConverters.stringListToByteList())); return null; } + if (isQueueing()) { + transaction.hvals(key); + return null; + } return jedis.hvals(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2450,14 +2484,18 @@ public class JedisConnection implements RedisConnection { // public Long publish(byte[] channel, byte[] message) { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } try { if (isPipelined()) { pipeline(new JedisResult(pipeline.publish(channel, message))); return null; } + } catch (Exception ex) { + throw convertJedisAccessException(ex); + } + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + try { return jedis.publish(channel, message); } catch (Exception ex) { throw convertJedisAccessException(ex); 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 9e0d9089a..b001f1de5 100644 --- a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java @@ -106,6 +106,7 @@ public abstract class AbstractConnectionIntegrationTests { connection = null; } + @Test public void testSelect() { // Make sure this doesn't throw Exception connection.select(1); @@ -1838,6 +1839,13 @@ public abstract class AbstractConnectionIntegrationTests { } } + @Test + public void testLastSave() { + actual.add(connection.lastSave()); + List results = getResults(); + assertNotNull(results.get(0)); + } + protected void verifyResults(List expected) { assertEquals(expected, getResults()); } diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineIntegrationTests.java index 0988d2c30..c5f3ddec3 100644 --- a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineIntegrationTests.java @@ -15,11 +15,17 @@ */ package org.springframework.data.redis.connection.jedis; +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.List; + import org.junit.After; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.data.redis.connection.AbstractConnectionPipelineIntegrationTests; +import org.springframework.data.redis.connection.DefaultStringRedisConnection; import org.springframework.test.annotation.IfProfileValue; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -53,14 +59,6 @@ public class JedisConnectionPipelineIntegrationTests extends public void testGetConfig() { } - @Ignore("DATAREDIS-143 MultiResponseBuilder trying to cast QUEUED to a List") - public void testWatch() { - } - - @Ignore("DATAREDIS-143 MultiResponseBuilder trying to cast QUEUED to a List") - public void testUnwatch() { - } - @Ignore("https://github.com/xetorthio/jedis/pull/389 Pipeline tries to return List instead of Long on sort") public void testSortStore() { } @@ -73,17 +71,51 @@ public class JedisConnectionPipelineIntegrationTests extends public void testSortStoreNullParams() { } - @Ignore("DATAREDIS-143 Jedis ClassCastExceptions closing pipeline on certain ops") - public void testMultiExec() { - } - - @Ignore("DATAREDIS-143 Jedis NPE closing pipeline on certain ops") + @Ignore("https://github.com/xetorthio/jedis/issues/438 Cannot get results from Pipeline after tx discard called") public void testMultiDiscard() { } - @Ignore("DATAREDIS-143 Jedis ClassCastExceptions closing pipeline on certain ops") @Test - public void testErrorInTx() { + public void testWatch() { + connection.set("testitnow", "willdo"); + connection.watch("testitnow".getBytes()); + // Jedis doesn't actually send commands until you close the pipeline + getResults(); + DefaultStringRedisConnection conn2 = new DefaultStringRedisConnection( + connectionFactory.getConnection()); + conn2.set("testitnow", "something"); + conn2.close(); + // Reopen the pipeline + initConnection(); + connection.multi(); + connection.set("testitnow", "somethingelse"); + actual.add(connection.exec()); + actual.add(connection.get("testitnow")); + verifyResults(Arrays.asList(new Object[] { null, "something" })); + } + + @SuppressWarnings("unchecked") + @Test + public void testUnwatch() throws Exception { + connection.set("testitnow", "willdo"); + connection.watch("testitnow".getBytes()); + // Jedis doesn't actually send commands until you close the pipeline + getResults(); + initConnection(); + connection.unwatch(); + // Jedis doesn't actually send commands until you close the pipeline + getResults(); + initConnection(); + connection.multi(); + DefaultStringRedisConnection conn2 = new DefaultStringRedisConnection( + connectionFactory.getConnection()); + conn2.set("testitnow", "something"); + connection.set("testitnow", "somethingelse"); + connection.get("testitnow"); + actual.add(connection.exec()); + List results = getResults(); + List execResults = (List) results.get(0); + assertEquals("somethingelse", new String((byte[]) execResults.get(1))); } // Unsupported Ops diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineTxIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineTxIntegrationTests.java new file mode 100644 index 000000000..fbdcdf3c9 --- /dev/null +++ b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineTxIntegrationTests.java @@ -0,0 +1,80 @@ +package org.springframework.data.redis.connection.jedis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Ignore; +import org.junit.Test; +import org.springframework.data.redis.connection.RedisPipelineException; + +public class JedisConnectionPipelineTxIntegrationTests extends JedisConnectionTransactionIntegrationTests { + + @Ignore("Jedis issue: Pipeline tries to return String instead of List") + @Test + public void testGetConfig() { + } + + @Ignore("https://github.com/xetorthio/jedis/pull/389 Pipeline tries to return List instead of Long on sort") + public void testSortStore() { + } + + @Ignore("Jedis issue: Pipeline tries to return Long instead of List on sort with no params") + public void testSortNullParams() { + } + + @Ignore("https://github.com/xetorthio/jedis/pull/389 Pipeline tries to return Long instead of List on sort with no params") + public void testSortStoreNullParams() { + } + + @Test + public void testEcho() { + actual.add(connection.echo("Hello World")); + verifyResults(Arrays.asList(new Object[] { "Hello World" })); + } + + @Test(expected=RedisPipelineException.class) + public void exceptionExecuteNative() throws Exception { + connection.execute("set", "foo"); + connection.execute("ZadD", getClass() + "#foo\t0.90\titem"); + getResults(); + } + + @Test + public void testLastSave() { + connection.lastSave(); + List results = getResults(); + assertNotNull(results.get(0)); + } + + protected void initConnection() { + connection.openPipeline(); + connection.multi(); + } + + @SuppressWarnings("unchecked") + protected List getResults() { + assertNull(connection.exec()); + List pipelined = connection.closePipeline(); + // We expect only the results of exec to be in the closed pipeline + assertEquals(1,pipelined.size()); + List txResults = (List)pipelined.get(0); + // Return exec results and this test should behave exactly like its superclass + return convertResults(txResults); + } + + @SuppressWarnings("unchecked") + protected List getResultsNoConversion() { + assertNull(connection.exec()); + List pipelined = connection.closePipeline(); + // We expect only the results of exec to be in the closed pipeline + assertEquals(1,pipelined.size()); + List txResults = (List)pipelined.get(0); + // Return exec results and this test should behave exactly like its superclass + return txResults; + } + +} diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionTransactionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionTransactionIntegrationTests.java index ebdd8f260..a374e8ecb 100644 --- a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionTransactionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionTransactionIntegrationTests.java @@ -135,6 +135,11 @@ public class JedisConnectionTransactionIntegrationTests extends super.testBitSet(); } + @Test(expected = UnsupportedOperationException.class) + public void testBitGet() { + connection.getBit("bitly", 1l); + } + @Test(expected = UnsupportedOperationException.class) public void testBitCount() { connection.bitCount("foo"); @@ -212,7 +217,7 @@ public class JedisConnectionTransactionIntegrationTests extends @Test(expected = UnsupportedOperationException.class) public void testZRevRangeByScoreWithScoresOffsetCount() { - super.testZRevRangeByScoreWithScoresOffsetCount(); + byteConnection.zRevRangeByScoreWithScores("myset".getBytes(), 0d, 3d, 0, 1); } @Test(expected = UnsupportedOperationException.class) @@ -361,11 +366,21 @@ public class JedisConnectionTransactionIntegrationTests extends super.testEcho(); } + @Test(expected = UnsupportedOperationException.class) + public void testSelect() { + super.testSelect(); + } + + @Test(expected = UnsupportedOperationException.class) + public void testLastSave() { + super.testLastSave(); + } + @Test public void exceptionExecuteNative() throws Exception { actual.add(connection.execute("ZadD", getClass() + "#foo\t0.90\titem")); try { - // Syntax error on queued commands are swallowed and no results are + // In Redis 2.4, syntax error on queued commands are swallowed and no results are // returned verifyResults(Arrays.asList(new Object[] {})); if (RedisVersionUtils.atLeast("2.6.5", connection)) { diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionTransactionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionTransactionIntegrationTests.java index 6f156764b..ec8ff222f 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionTransactionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionTransactionIntegrationTests.java @@ -221,6 +221,11 @@ public class LettuceConnectionTransactionIntegrationTests extends } } + @Test(expected=UnsupportedOperationException.class) + public void testSelect() { + super.testSelect(); + } + @SuppressWarnings({ "rawtypes", "unchecked" }) @Override protected Object convertResult(Object result) {