From 2a431091fb0b613c0e36d6832df759abfd5ea4f2 Mon Sep 17 00:00:00 2001 From: ddelautre Date: Fri, 4 Feb 2011 14:55:19 -0500 Subject: [PATCH] Change JedisConnection to use pipelining --- .../connection/jedis/JedisConnection.java | 478 +++++++++++++++++- 1 file changed, 474 insertions(+), 4 deletions(-) diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisConnection.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisConnection.java index a0f84e115..d45227d12 100644 --- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisConnection.java +++ b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/connection/jedis/JedisConnection.java @@ -41,6 +41,7 @@ import redis.clients.jedis.BinaryTransaction; import redis.clients.jedis.Client; import redis.clients.jedis.Jedis; import redis.clients.jedis.Pipeline; +import redis.clients.jedis.Protocol; import redis.clients.jedis.SortingParams; import redis.clients.jedis.Transaction; import redis.clients.jedis.ZParams; @@ -201,6 +202,16 @@ public class JedisConnection implements RedisConnection { return null; } + if (isPipelined()) { + if (sortParams != null) { + pipeline.sort(key, sortParams); + } + else { + pipeline.sort(key); + } + + return null; + } return (sortParams != null ? jedis.sort(key, sortParams) : jedis.sort(key)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -223,6 +234,16 @@ public class JedisConnection implements RedisConnection { return null; } + if (isPipelined()) { + if (sortParams != null) { + pipeline.sort(key, sortParams, sortKey); + } + else { + pipeline.sort(key, sortKey); + } + + return null; + } return (sortParams != null ? jedis.sort(key, sortParams, sortKey) : jedis.sort(key, sortKey)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -236,6 +257,9 @@ public class JedisConnection implements RedisConnection { transaction.dbSize(); return null; } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } return jedis.dbSize(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -250,6 +274,9 @@ public class JedisConnection implements RedisConnection { transaction.flushDB(); return; } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } jedis.flushDB(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -263,6 +290,9 @@ public class JedisConnection implements RedisConnection { transaction.flushAll(); return; } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } jedis.flushAll(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -275,6 +305,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.bgsave(); + return; + } jedis.bgsave(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -287,6 +321,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.bgrewriteaof(); + return; + } jedis.bgrewriteaof(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -299,6 +337,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.save(); + return; + } jedis.save(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -311,6 +353,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.configGet(param); + return null; + } return jedis.configGet(param); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -323,6 +369,9 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } return JedisUtils.info(jedis.info()); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -335,6 +384,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.lastsave(); + return null; + } return jedis.lastsave(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -347,6 +400,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.configSet(param, value); + return; + } jedis.configSet(param, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -360,6 +417,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.configResetStat(); + return; + } jedis.configResetStat(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -372,6 +433,9 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } jedis.shutdown(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -384,6 +448,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.echo(message); + return null; + } return jedis.echo(message); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -397,6 +465,9 @@ public class JedisConnection implements RedisConnection { transaction.ping(); return null; } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } return jedis.ping(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -410,6 +481,10 @@ public class JedisConnection implements RedisConnection { transaction.del(keys); return null; } + if (isPipelined()) { + pipeline.del(keys); + return null; + } return jedis.del(keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -428,6 +503,10 @@ public class JedisConnection implements RedisConnection { @Override public List exec() { try { + if (isPipelined()) { + pipeline.exec(); + return null; + } return transaction.exec(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -441,6 +520,10 @@ public class JedisConnection implements RedisConnection { transaction.exists(key); return null; } + if (isPipelined()) { + pipeline.exists(key); + return null; + } return jedis.exists(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -454,6 +537,10 @@ public class JedisConnection implements RedisConnection { transaction.expire(key, (int) seconds); return null; } + if (isPipelined()) { + pipeline.expire(key, (int) seconds); + return null; + } return (jedis.expire(key, (int) seconds) == 1); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -467,6 +554,10 @@ public class JedisConnection implements RedisConnection { transaction.expireAt(key, unixTime); return null; } + if (isPipelined()) { + pipeline.expireAt(key, unixTime); + return null; + } return (jedis.expireAt(key, unixTime) == 1); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -480,6 +571,10 @@ public class JedisConnection implements RedisConnection { transaction.keys(pattern); return null; } + if (isPipelined()) { + pipeline.keys(pattern); + return null; + } return (jedis.keys(pattern)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -491,8 +586,11 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { return; } - try { + if (isPipelined()) { + pipeline.multi(); + return; + } jedis.multi(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -506,6 +604,10 @@ public class JedisConnection implements RedisConnection { client.persist(key); return null; } + if (isPipelined()) { + pipeline.persist(key); + return null; + } return (jedis.persist(key) == 1); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -519,6 +621,9 @@ public class JedisConnection implements RedisConnection { transaction.randomBinaryKey(); return null; } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } return jedis.randomBinaryKey(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -532,6 +637,10 @@ public class JedisConnection implements RedisConnection { transaction.rename(oldName, newName); return; } + if (isPipelined()) { + pipeline.rename(oldName, newName); + return; + } jedis.rename(oldName, newName); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -545,6 +654,10 @@ public class JedisConnection implements RedisConnection { transaction.renamenx(oldName, newName); return null; } + if (isPipelined()) { + pipeline.renamenx(oldName, newName); + return null; + } return (jedis.renamenx(oldName, newName) == 1); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -558,6 +671,9 @@ public class JedisConnection implements RedisConnection { transaction.select(dbIndex); return; } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } jedis.select(dbIndex); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -571,6 +687,10 @@ public class JedisConnection implements RedisConnection { transaction.ttl(key); return null; } + if (isPipelined()) { + pipeline.ttl(key); + return null; + } return jedis.ttl(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -584,6 +704,10 @@ public class JedisConnection implements RedisConnection { transaction.type(key); return null; } + if (isPipelined()) { + pipeline.type(key); + return null; + } return DataType.fromCode(jedis.type(key)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -605,10 +729,13 @@ public class JedisConnection implements RedisConnection { // ignore (as watch not allowed in multi) return; } - try { for (byte[] key : keys) { - jedis.watch(key); + if (isPipelined()) { + pipeline.watch(key); + } else { + jedis.watch(key); + } } } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -626,6 +753,10 @@ public class JedisConnection implements RedisConnection { transaction.get(key); return null; } + if (isPipelined()) { + pipeline.get(key); + return null; + } return jedis.get(key); } catch (Exception ex) { @@ -640,6 +771,10 @@ public class JedisConnection implements RedisConnection { transaction.set(key, value); return; } + if (isPipelined()) { + pipeline.set(key, value); + return; + } jedis.set(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -654,6 +789,10 @@ public class JedisConnection implements RedisConnection { transaction.getSet(key, value); return null; } + if (isPipelined()) { + pipeline.getSet(key, value); + return null; + } return jedis.getSet(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -667,6 +806,10 @@ public class JedisConnection implements RedisConnection { transaction.append(key, value); return null; } + if (isPipelined()) { + pipeline.append(key, value); + return null; + } return jedis.append(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -680,6 +823,10 @@ public class JedisConnection implements RedisConnection { transaction.mget(keys); return null; } + if (isPipelined()) { + pipeline.mget(keys); + return null; + } return jedis.mget(keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -693,6 +840,10 @@ public class JedisConnection implements RedisConnection { transaction.mset(JedisUtils.convert(tuples)); return; } + if (isPipelined()) { + pipeline.mset(JedisUtils.convert(tuples)); + return; + } jedis.mset(JedisUtils.convert(tuples)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -706,6 +857,10 @@ public class JedisConnection implements RedisConnection { transaction.msetnx(JedisUtils.convert(tuples)); return; } + if (isPipelined()) { + pipeline.msetnx(JedisUtils.convert(tuples)); + return; + } jedis.msetnx(JedisUtils.convert(tuples)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -719,6 +874,10 @@ public class JedisConnection implements RedisConnection { transaction.setex(key, (int) time, value); return; } + if (isPipelined()) { + pipeline.setex(key, (int) time, value); + return; + } jedis.setex(key, (int) time, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -732,6 +891,10 @@ public class JedisConnection implements RedisConnection { transaction.setnx(key, value); return null; } + if (isPipelined()) { + pipeline.setnx(key, value); + return null; + } return JedisUtils.convertCodeReply(jedis.setnx(key, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -745,6 +908,10 @@ public class JedisConnection implements RedisConnection { transaction.substr(key, (int) start, (int) end); return null; } + if (isPipelined()) { + pipeline.substr(key, (int) start, (int) end); + return null; + } return jedis.substr(key, (int) start, (int) end); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -758,6 +925,10 @@ public class JedisConnection implements RedisConnection { transaction.decr(key); return null; } + if (isPipelined()) { + pipeline.decr(key); + return null; + } return jedis.decr(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -771,6 +942,10 @@ public class JedisConnection implements RedisConnection { transaction.decrBy(key, (int) value); return null; } + if (isPipelined()) { + pipeline.decrBy(key, (int) value); + return null; + } return jedis.decrBy(key, (int) value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -784,6 +959,10 @@ public class JedisConnection implements RedisConnection { transaction.incr(key); return null; } + if (isPipelined()) { + pipeline.incr(key); + return null; + } return jedis.incr(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -797,6 +976,10 @@ public class JedisConnection implements RedisConnection { transaction.incrBy(key, (int) value); return null; } + if (isPipelined()) { + pipeline.incrBy(key, (int) value); + return null; + } return jedis.incrBy(key, (int) value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -811,6 +994,9 @@ public class JedisConnection implements RedisConnection { // return null; throw new UnsupportedOperationException(); } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } return (jedis.getbit(key, offset) == 0 ? Boolean.FALSE : Boolean.TRUE); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -825,6 +1011,9 @@ public class JedisConnection implements RedisConnection { // return; throw new UnsupportedOperationException(); } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } jedis.setbit(key, offset, JedisUtils.asBit(value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -842,6 +1031,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.strlen(key); + return null; + } return jedis.strlen(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -859,6 +1052,10 @@ public class JedisConnection implements RedisConnection { transaction.lpush(key, value); return null; } + if (isPipelined()) { + pipeline.lpush(key, value); + return null; + } return jedis.lpush(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -872,6 +1069,10 @@ public class JedisConnection implements RedisConnection { transaction.rpush(key, value); return null; } + if (isPipelined()) { + pipeline.rpush(key, value); + return null; + } return jedis.rpush(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -884,6 +1085,15 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + final List args = new ArrayList(); + for (final byte[] arg : keys) { + args.add(arg); + } + args.add(Protocol.toByteArray(timeout)); + pipeline.blpop(args.toArray(new byte[args.size()][])); + return null; + } return jedis.blpop(timeout, keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -896,6 +1106,15 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + final List args = new ArrayList(); + for (final byte[] arg : keys) { + args.add(arg); + } + args.add(Protocol.toByteArray(timeout)); + pipeline.brpop(args.toArray(new byte[args.size()][])); + return null; + } return jedis.brpop(timeout, keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -909,6 +1128,10 @@ public class JedisConnection implements RedisConnection { transaction.lindex(key, (int) index); return null; } + if (isPipelined()) { + pipeline.lindex(key, (int) index); + return null; + } return jedis.lindex(key, (int) index); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -923,6 +1146,10 @@ public class JedisConnection implements RedisConnection { // return null; throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.linsert(key, JedisUtils.convertPosition(where), pivot, value); + return null; + } return jedis.linsert(key, JedisUtils.convertPosition(where), pivot, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -936,6 +1163,10 @@ public class JedisConnection implements RedisConnection { transaction.llen(key); return null; } + if (isPipelined()) { + pipeline.llen(key); + return null; + } return jedis.llen(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -949,6 +1180,10 @@ public class JedisConnection implements RedisConnection { transaction.lpop(key); return null; } + if (isPipelined()) { + pipeline.lpop(key); + return null; + } return jedis.lpop(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -962,6 +1197,10 @@ public class JedisConnection implements RedisConnection { transaction.lrange(key, (int) start, (int) end); return null; } + if (isPipelined()) { + pipeline.lrange(key, (int) start, (int) end); + return null; + } return jedis.lrange(key, (int) start, (int) end); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -975,6 +1214,10 @@ public class JedisConnection implements RedisConnection { transaction.lrem(key, (int) count, value); return null; } + if (isPipelined()) { + pipeline.lrem(key, (int) count, value); + return null; + } return jedis.lrem(key, (int) count, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -988,6 +1231,10 @@ public class JedisConnection implements RedisConnection { transaction.lset(key, (int) index, value); return; } + if (isPipelined()) { + pipeline.lset(key, (int) index, value); + return; + } jedis.lset(key, (int) index, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1001,6 +1248,10 @@ public class JedisConnection implements RedisConnection { transaction.ltrim(key, (int) start, (int) end); return; } + if (isPipelined()) { + pipeline.ltrim(key, (int) start, (int) end); + return; + } jedis.ltrim(key, (int) start, (int) end); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1014,6 +1265,10 @@ public class JedisConnection implements RedisConnection { transaction.rpop(key); return null; } + if (isPipelined()) { + pipeline.rpop(key); + return null; + } return jedis.rpop(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1027,6 +1282,10 @@ public class JedisConnection implements RedisConnection { transaction.rpoplpush(srcKey, dstKey); return null; } + if (isPipelined()) { + pipeline.rpoplpush(srcKey, dstKey); + return null; + } return jedis.rpoplpush(srcKey, dstKey); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1039,6 +1298,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.brpoplpush(srcKey, dstKey, timeout); + return null; + } return jedis.brpoplpush(srcKey, dstKey, timeout); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1051,6 +1314,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.lpushx(key, value); + return null; + } return jedis.lpushx(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1063,6 +1330,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.rpushx(key, value); + return null; + } return jedis.rpushx(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1081,6 +1352,10 @@ public class JedisConnection implements RedisConnection { transaction.sadd(key, value); return null; } + if (isPipelined()) { + pipeline.sadd(key, value); + return null; + } return (jedis.sadd(key, value) == 1); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1094,6 +1369,10 @@ public class JedisConnection implements RedisConnection { transaction.scard(key); return null; } + if (isPipelined()) { + pipeline.scard(key); + return null; + } return jedis.scard(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1107,6 +1386,10 @@ public class JedisConnection implements RedisConnection { transaction.sdiff(keys); return null; } + if (isPipelined()) { + pipeline.sdiff(keys); + return null; + } return jedis.sdiff(keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1120,6 +1403,10 @@ public class JedisConnection implements RedisConnection { transaction.sdiffstore(destKey, keys); return; } + if (isPipelined()) { + pipeline.sdiffstore(destKey, keys); + return; + } jedis.sdiffstore(destKey, keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1133,6 +1420,10 @@ public class JedisConnection implements RedisConnection { transaction.sinter(keys); return null; } + if (isPipelined()) { + pipeline.sinter(keys); + return null; + } return jedis.sinter(keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1146,6 +1437,10 @@ public class JedisConnection implements RedisConnection { transaction.sinterstore(destKey, keys); return; } + if (isPipelined()) { + pipeline.sinterstore(destKey, keys); + return; + } jedis.sinterstore(destKey, keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1159,6 +1454,10 @@ public class JedisConnection implements RedisConnection { transaction.sismember(key, value); return null; } + if (isPipelined()) { + pipeline.sismember(key, value); + return null; + } return jedis.sismember(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1172,6 +1471,10 @@ public class JedisConnection implements RedisConnection { transaction.smembers(key); return null; } + if (isPipelined()) { + pipeline.smembers(key); + return null; + } return jedis.smembers(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1185,6 +1488,10 @@ public class JedisConnection implements RedisConnection { transaction.smove(srcKey, destKey, value); return null; } + if (isPipelined()) { + pipeline.smove(srcKey, destKey, value); + return null; + } return JedisUtils.convertCodeReply(jedis.smove(srcKey, destKey, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1198,6 +1505,10 @@ public class JedisConnection implements RedisConnection { transaction.spop(key); return null; } + if (isPipelined()) { + pipeline.spop(key); + return null; + } return jedis.spop(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1211,6 +1522,10 @@ public class JedisConnection implements RedisConnection { transaction.srandmember(key); return null; } + if (isPipelined()) { + pipeline.srandmember(key); + return null; + } return jedis.srandmember(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1224,6 +1539,10 @@ public class JedisConnection implements RedisConnection { transaction.srem(key, value); return null; } + if (isPipelined()) { + pipeline.srem(key, value); + return null; + } return JedisUtils.convertCodeReply(jedis.srem(key, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1237,6 +1556,10 @@ public class JedisConnection implements RedisConnection { transaction.sunion(keys); return null; } + if (isPipelined()) { + pipeline.sunion(keys); + return null; + } return jedis.sunion(keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1250,6 +1573,10 @@ public class JedisConnection implements RedisConnection { transaction.sunionstore(destKey, keys); return; } + if (isPipelined()) { + pipeline.sunionstore(destKey, keys); + return; + } jedis.sunionstore(destKey, keys); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1267,6 +1594,10 @@ public class JedisConnection implements RedisConnection { transaction.zadd(key, score, value); return null; } + if (isPipelined()) { + pipeline.zadd(key, score, value); + return null; + } return JedisUtils.convertCodeReply(jedis.zadd(key, score, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1280,6 +1611,10 @@ public class JedisConnection implements RedisConnection { transaction.zcard(key); return null; } + if (isPipelined()) { + pipeline.zcard(key); + return null; + } return jedis.zcard(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1292,6 +1627,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isQueueing()) { + pipeline.zcount(key, min, max); + return null; + } return jedis.zcount(key, min, max); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1305,6 +1644,10 @@ public class JedisConnection implements RedisConnection { transaction.zincrby(key, increment, value); return null; } + if (isPipelined()) { + pipeline.zincrby(key, increment, value); + return null; + } return jedis.zincrby(key, increment, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1319,6 +1662,9 @@ public class JedisConnection implements RedisConnection { } ZParams zparams = new ZParams().weights(weights).aggregate( redis.clients.jedis.ZParams.Aggregate.valueOf(aggregate.name())); + if (isPipelined()) { + pipeline.zinterstore(destKey, zparams, sets); + } return jedis.zinterstore(destKey, zparams, sets); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1331,6 +1677,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isQueueing()) { + pipeline.zinterstore(destKey, sets); + return null; + } return jedis.zinterstore(destKey, sets); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1344,6 +1694,10 @@ public class JedisConnection implements RedisConnection { transaction.zrange(key, (int) start, (int) end); return null; } + if (isPipelined()) { + pipeline.zrange(key, (int) start, (int) end); + return null; + } return jedis.zrange(key, (int) start, (int) end); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1357,6 +1711,10 @@ public class JedisConnection implements RedisConnection { transaction.zrangeWithScores(key, (int) start, (int) end); return null; } + if (isPipelined()) { + pipeline.zrangeWithScores(key, (int) start, (int) end); + return null; + } return JedisUtils.convertJedisTuple(jedis.zrangeWithScores(key, (int) start, (int) end)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1369,6 +1727,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.zrangeByScore(key, min, max); + return null; + } return jedis.zrangeByScore(key, min, max); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1381,6 +1743,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.zrangeByScoreWithScores(key, min, max); + return null; + } return JedisUtils.convertJedisTuple(jedis.zrangeByScoreWithScores(key, min, max)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1394,6 +1760,10 @@ public class JedisConnection implements RedisConnection { transaction.zrangeWithScores(key, (int) start, (int) end); return null; } + if (isPipelined()) { + pipeline.zrangeWithScores(key, (int) start, (int) end); + return null; + } return JedisUtils.convertJedisTuple(jedis.zrangeByScoreWithScores(key, (int) start, (int) end)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1406,6 +1776,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.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); @@ -1418,6 +1792,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.zrangeByScoreWithScores(key, min, max, (int) offset, (int) count); + return null; + } return JedisUtils.convertJedisTuple(jedis.zrangeByScoreWithScores(key, min, max, (int) offset, (int) count)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1431,6 +1809,10 @@ public class JedisConnection implements RedisConnection { transaction.zrank(key, value); return null; } + if (isPipelined()) { + pipeline.zrank(key, value); + return null; + } return jedis.zrank(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1444,6 +1826,10 @@ public class JedisConnection implements RedisConnection { transaction.zrem(key, value); return null; } + if (isPipelined()) { + pipeline.zrem(key, value); + return null; + } return JedisUtils.convertCodeReply(jedis.zrem(key, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1456,6 +1842,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.zremrangeByRank(key, (int) start, (int) end); + return null; + } return jedis.zremrangeByRank(key, (int) start, (int) end); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1468,6 +1858,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.zremrangeByScore(key, min, max); + return null; + } return jedis.zremrangeByScore(key, min, max); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1481,6 +1875,10 @@ public class JedisConnection implements RedisConnection { transaction.zrevrange(key, (int) start, (int) end); return null; } + if (isPipelined()) { + pipeline.zrevrange(key, (int) start, (int) end); + return null; + } return jedis.zrevrange(key, (int) start, (int) end); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1494,6 +1892,10 @@ public class JedisConnection implements RedisConnection { transaction.zrevrank(key, value); return null; } + if (isPipelined()) { + pipeline.zrevrank(key, value); + return null; + } return jedis.zrevrank(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1507,6 +1909,10 @@ public class JedisConnection implements RedisConnection { transaction.zscore(key, value); return null; } + if (isPipelined()) { + pipeline.zscore(key, value); + return null; + } return jedis.zscore(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1521,6 +1927,10 @@ public class JedisConnection implements RedisConnection { } ZParams zparams = new ZParams().weights(weights).aggregate( redis.clients.jedis.ZParams.Aggregate.valueOf(aggregate.name())); + if (isPipelined()) { + pipeline.zunionstore(destKey, zparams, sets); + return null; + } return jedis.zunionstore(destKey, zparams, sets); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1533,6 +1943,10 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + pipeline.zunionstore(destKey, sets); + return null; + } return jedis.zunionstore(destKey, sets); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1550,6 +1964,10 @@ public class JedisConnection implements RedisConnection { transaction.hset(key, field, value); return null; } + if (isPipelined()) { + pipeline.hset(key, field, value); + return null; + } return JedisUtils.convertCodeReply(jedis.hset(key, field, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1563,6 +1981,10 @@ public class JedisConnection implements RedisConnection { transaction.hsetnx(key, field, value); return null; } + if (isPipelined()) { + pipeline.hsetnx(key, field, value); + return null; + } return JedisUtils.convertCodeReply(jedis.hsetnx(key, field, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1576,6 +1998,10 @@ public class JedisConnection implements RedisConnection { transaction.hdel(key, field); return null; } + if (isPipelined()) { + pipeline.hdel(key, field); + return null; + } return JedisUtils.convertCodeReply(jedis.hdel(key, field)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1589,6 +2015,10 @@ public class JedisConnection implements RedisConnection { transaction.hexists(key, field); return null; } + if (isPipelined()) { + pipeline.hexists(key, field); + return null; + } return jedis.hexists(key, field); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1602,6 +2032,10 @@ public class JedisConnection implements RedisConnection { transaction.hget(key, field); return null; } + if (isPipelined()) { + pipeline.hget(key, field); + return null; + } return jedis.hget(key, field); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1615,6 +2049,10 @@ public class JedisConnection implements RedisConnection { transaction.hgetAll(key); return null; } + if (isPipelined()) { + pipeline.hgetAll(key); + return null; + } return jedis.hgetAll(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1628,6 +2066,10 @@ public class JedisConnection implements RedisConnection { transaction.hincrBy(key, field, (int) delta); return null; } + if (isPipelined()) { + pipeline.hincrBy(key, field, (int) delta); + return null; + } return jedis.hincrBy(key, field, (int) delta); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1641,6 +2083,10 @@ public class JedisConnection implements RedisConnection { transaction.hkeys(key); return null; } + if (isPipelined()) { + pipeline.hkeys(key); + return null; + } return jedis.hkeys(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1654,6 +2100,10 @@ public class JedisConnection implements RedisConnection { transaction.hlen(key); return null; } + if (isPipelined()) { + pipeline.hlen(key); + return null; + } return jedis.hlen(key); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1667,6 +2117,10 @@ public class JedisConnection implements RedisConnection { transaction.hmget(key, fields); return null; } + if (isPipelined()) { + pipeline.hmget(key, fields); + return null; + } return jedis.hmget(key, fields); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1680,6 +2134,10 @@ public class JedisConnection implements RedisConnection { transaction.hmset(key, tuple); return; } + if (isPipelined()) { + pipeline.hmset(key, tuple); + return; + } jedis.hmset(key, tuple); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1693,6 +2151,10 @@ public class JedisConnection implements RedisConnection { transaction.hvals(key); return null; } + if (isPipelined()) { + pipeline.hvals(key); + return null; + } return new ArrayList(jedis.hvals(key)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1709,7 +2171,9 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } - + if (isPipelined()) { + throw new UnsupportedOperationException(); + } return jedis.publish(channel, message); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1737,6 +2201,9 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } BinaryJedisPubSub jedisPubSub = JedisUtils.adaptPubSub(listener); @@ -1758,6 +2225,9 @@ public class JedisConnection implements RedisConnection { if (isQueueing()) { throw new UnsupportedOperationException(); } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } BinaryJedisPubSub jedisPubSub = JedisUtils.adaptPubSub(listener);