Revert "removed @Override annotations that cause problems in JDK 5 on interface methods"
This reverts commit 41c5f7e0bc.
Spring Redis depends on JDK 6 (at API level).
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.redis.config;
|
||||
|
||||
import org.springframework.beans.factory.xml.NamespaceHandler;
|
||||
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
|
||||
/**
|
||||
@@ -24,6 +25,7 @@ import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
*/
|
||||
class RedisNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
registerBeanDefinitionParser("listener-container", new RedisListenerContainerParser());
|
||||
}
|
||||
|
||||
@@ -32,10 +32,12 @@ public class DefaultMessage implements Message {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getChannel() {
|
||||
return (channel != null ? channel.clone() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBody() {
|
||||
return (body != null ? body.clone() : null);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ public class DefaultSortParameters implements SortParameters {
|
||||
setGetPattern(getPattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getByPattern() {
|
||||
return byPattern;
|
||||
}
|
||||
@@ -76,6 +77,7 @@ public class DefaultSortParameters implements SortParameters {
|
||||
this.byPattern = byPattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Range getLimit() {
|
||||
return limit;
|
||||
}
|
||||
@@ -84,6 +86,7 @@ public class DefaultSortParameters implements SortParameters {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[][] getGetPattern() {
|
||||
return getPattern.toArray(new byte[getPattern.size()][]);
|
||||
}
|
||||
@@ -100,6 +103,7 @@ public class DefaultSortParameters implements SortParameters {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order getOrder() {
|
||||
return order;
|
||||
}
|
||||
@@ -108,6 +112,7 @@ public class DefaultSortParameters implements SortParameters {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isAlphabetic() {
|
||||
return alphabetic;
|
||||
}
|
||||
|
||||
@@ -621,415 +621,518 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long append(String key, String value) {
|
||||
return delegate.append(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> bLPop(int timeout, String... keys) {
|
||||
return deserialize(delegate.bLPop(timeout, serializeMulti(keys)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> bRPop(int timeout, String... keys) {
|
||||
return deserialize(delegate.bRPop(timeout, serializeMulti(keys)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String bRPopLPush(int timeout, String srcKey, String dstKey) {
|
||||
return deserialize(delegate.bRPopLPush(timeout, serialize(srcKey), serialize(dstKey)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long decr(String key) {
|
||||
return delegate.decr(serialize(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long decrBy(String key, long value) {
|
||||
return delegate.decrBy(serialize(key), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long del(String... keys) {
|
||||
return delegate.del(serializeMulti(keys));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String echo(String message) {
|
||||
return deserialize(delegate.echo(serialize(message)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean exists(String key) {
|
||||
return delegate.exists(serialize(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expire(String key, long seconds) {
|
||||
return delegate.expire(serialize(key), seconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expireAt(String key, long unixTime) {
|
||||
return delegate.expireAt(serialize(key), unixTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String key) {
|
||||
return deserialize(delegate.get(serialize(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getBit(String key, long offset) {
|
||||
return delegate.getBit(serialize(key), offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRange(String key, long start, long end) {
|
||||
return deserialize(delegate.getRange(serialize(key), start, end));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSet(String key, String value) {
|
||||
return deserialize(delegate.getSet(serialize(key), serialize(value)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hDel(String key, String field) {
|
||||
return delegate.hDel(serialize(key), serialize(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hExists(String key, String field) {
|
||||
return delegate.hExists(serialize(key), serialize(field));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String hGet(String key, String field) {
|
||||
return deserialize(delegate.hGet(serialize(key), serialize(field)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> hGetAll(String key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long hIncrBy(String key, String field, long delta) {
|
||||
return delegate.hIncrBy(serialize(key), serialize(field), delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> hKeys(String key) {
|
||||
return deserialize(delegate.hKeys(serialize(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long hLen(String key) {
|
||||
return delegate.hLen(serialize(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> hMGet(String key, String... fields) {
|
||||
return deserialize(delegate.hMGet(serialize(key), serializeMulti(fields)));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void hMSet(String key, Map<String, String> hashes) {
|
||||
delegate.hMSet(serialize(key), serialize(hashes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hSet(String key, String field, String value) {
|
||||
return delegate.hSet(serialize(key), serialize(field), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hSetNX(String key, String field, String value) {
|
||||
return delegate.hSetNX(serialize(key), serialize(field), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> hVals(String key) {
|
||||
return deserialize(delegate.hVals(serialize(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long incr(String key) {
|
||||
return delegate.incr(serialize(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long incrBy(String key, long value) {
|
||||
return delegate.incrBy(serialize(key), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> keys(String pattern) {
|
||||
return deserialize(delegate.keys(serialize(pattern)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String lIndex(String key, long index) {
|
||||
return deserialize(delegate.lIndex(serialize(key), index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lInsert(String key, Position where, String pivot, String value) {
|
||||
return delegate.lInsert(serialize(key), where, serialize(pivot), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lLen(String key) {
|
||||
return delegate.lLen(serialize(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String lPop(String key) {
|
||||
return deserialize(delegate.lPop(serialize(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lPush(String key, String value) {
|
||||
return delegate.lPush(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lPushX(String key, String value) {
|
||||
return delegate.lPushX(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> lRange(String key, long start, long end) {
|
||||
return deserialize(delegate.lRange(serialize(key), start, end));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lRem(String key, long count, String value) {
|
||||
return delegate.lRem(serialize(key), count, serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lSet(String key, long index, String value) {
|
||||
delegate.lSet(serialize(key), index, serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lTrim(String key, long start, long end) {
|
||||
delegate.lTrim(serialize(key), start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> mGet(String... keys) {
|
||||
return deserialize(delegate.mGet(serializeMulti(keys)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mSetNXString(Map<String, String> tuple) {
|
||||
delegate.mSetNX(serialize(tuple));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mSetString(Map<String, String> tuple) {
|
||||
delegate.mSet(serialize(tuple));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean persist(String key) {
|
||||
return delegate.persist(serialize(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean move(String key, int dbIndex) {
|
||||
return delegate.move(serialize(key), dbIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pSubscribe(MessageListener listener, String... patterns) {
|
||||
delegate.pSubscribe(listener, serializeMulti(patterns));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long publish(String channel, String message) {
|
||||
return delegate.publish(serialize(channel), serialize(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(String oldName, String newName) {
|
||||
delegate.rename(serialize(oldName), serialize(newName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean renameNX(String oldName, String newName) {
|
||||
return delegate.renameNX(serialize(oldName), serialize(newName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String rPop(String key) {
|
||||
return deserialize(delegate.rPop(serialize(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String rPopLPush(String srcKey, String dstKey) {
|
||||
return deserialize(delegate.rPopLPush(serialize(srcKey), serialize(dstKey)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rPush(String key, String value) {
|
||||
return delegate.rPush(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rPushX(String key, String value) {
|
||||
return delegate.rPushX(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sAdd(String key, String value) {
|
||||
return delegate.sAdd(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long sCard(String key) {
|
||||
return delegate.sCard(serialize(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> sDiff(String... keys) {
|
||||
return deserialize(delegate.sDiff(serializeMulti(keys)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sDiffStore(String destKey, String... keys) {
|
||||
delegate.sDiffStore(serialize(destKey), serializeMulti(keys));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(String key, String value) {
|
||||
delegate.set(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBit(String key, long offset, boolean value) {
|
||||
delegate.setBit(serialize(key), offset, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEx(String key, long seconds, String value) {
|
||||
delegate.setEx(serialize(key), seconds, serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean setNX(String key, String value) {
|
||||
return delegate.setNX(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRange(String key, String value, long start) {
|
||||
delegate.setRange(serialize(key), serialize(value), start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> sInter(String... keys) {
|
||||
return deserialize(delegate.sInter(serializeMulti(keys)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sInterStore(String destKey, String... keys) {
|
||||
delegate.sInterStore(serialize(destKey), serializeMulti(keys));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sIsMember(String key, String value) {
|
||||
return delegate.sIsMember(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> sMembers(String key) {
|
||||
return deserialize(delegate.sMembers(serialize(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sMove(String srcKey, String destKey, String value) {
|
||||
return delegate.sMove(serialize(srcKey), serialize(destKey), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long sort(String key, SortParameters params, String storeKey) {
|
||||
return delegate.sort(serialize(key), params, serialize(storeKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> sort(String key, SortParameters params) {
|
||||
return deserialize(delegate.sort(serialize(key), params));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sPop(String key) {
|
||||
return deserialize(delegate.sPop(serialize(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sRandMember(String key) {
|
||||
return deserialize(delegate.sRandMember(serialize(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sRem(String key, String value) {
|
||||
return delegate.sRem(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long strLen(String key) {
|
||||
return delegate.strLen(serialize(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(MessageListener listener, String... channels) {
|
||||
delegate.subscribe(listener, serializeMulti(channels));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> sUnion(String... keys) {
|
||||
return deserialize(delegate.sUnion(serializeMulti(keys)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sUnionStore(String destKey, String... keys) {
|
||||
delegate.sUnionStore(serialize(destKey), serializeMulti(keys));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long ttl(String key) {
|
||||
return delegate.ttl(serialize(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType type(String key) {
|
||||
return delegate.type(serialize(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean zAdd(String key, double score, String value) {
|
||||
return delegate.zAdd(serialize(key), score, serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zCard(String key) {
|
||||
return delegate.zCard(serialize(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zCount(String key, double min, double max) {
|
||||
return delegate.zCount(serialize(key), min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double zIncrBy(String key, double increment, String value) {
|
||||
return delegate.zIncrBy(serialize(key), increment, serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zInterStore(String destKey, Aggregate aggregate, int[] weights, String... sets) {
|
||||
return delegate.zInterStore(serialize(destKey), aggregate, weights, serializeMulti(sets));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zInterStore(String destKey, String... sets) {
|
||||
return delegate.zInterStore(serialize(destKey), serializeMulti(sets));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> zRange(String key, long start, long end) {
|
||||
return deserialize(delegate.zRange(serialize(key), start, end));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> zRangeByScore(String key, double min, double max, long offset, long count) {
|
||||
return deserialize(delegate.zRangeByScore(serialize(key), min, max, offset, count));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> zRangeByScore(String key, double min, double max) {
|
||||
return deserialize(delegate.zRangeByScore(serialize(key), min, max));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<StringTuple> zRangeByScoreWithScore(String key, double min, double max, long offset, long count) {
|
||||
return deserializeTuple(delegate.zRangeByScoreWithScore(serialize(key), min, max, offset, count));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<StringTuple> zRangeByScoreWithScore(String key, double min, double max) {
|
||||
return deserializeTuple(delegate.zRangeByScoreWithScore(serialize(key), min, max));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<StringTuple> zRangeWithScore(String key, long start, long end) {
|
||||
return deserializeTuple(delegate.zRangeWithScore(serialize(key), start, end));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRank(String key, String value) {
|
||||
return delegate.zRank(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean zRem(String key, String value) {
|
||||
return delegate.zRem(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRemRange(String key, long start, long end) {
|
||||
return delegate.zRemRange(serialize(key), start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRemRangeByScore(String key, double min, double max) {
|
||||
return delegate.zRemRangeByScore(serialize(key), min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> zRevRange(String key, long start, long end) {
|
||||
return deserialize(delegate.zRevRange(serialize(key), start, end));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<StringTuple> zRevRangeWithScore(String key, long start, long end) {
|
||||
return deserializeTuple(delegate.zRevRangeWithScore(serialize(key), start, end));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRevRank(String key, String value) {
|
||||
return delegate.zRevRank(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double zScore(String key, String value) {
|
||||
return delegate.zScore(serialize(key), serialize(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zUnionStore(String destKey, Aggregate aggregate, int[] weights, String... sets) {
|
||||
return delegate.zUnionStore(serialize(destKey), aggregate, weights, serializeMulti(sets));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zUnionStore(String destKey, String... sets) {
|
||||
return delegate.zUnionStore(serialize(destKey), serializeMulti(sets));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> closePipeline() {
|
||||
return delegate.closePipeline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPipelined() {
|
||||
return delegate.isPipelined();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openPipeline() {
|
||||
delegate.openPipeline();
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public class DefaultStringTuple extends DefaultTuple implements StringTuple {
|
||||
this.valueAsString = valueAsString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValueAsString() {
|
||||
return valueAsString;
|
||||
}
|
||||
|
||||
@@ -39,10 +39,12 @@ public class DefaultTuple implements Tuple {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ public class JedisConnection implements RedisConnection {
|
||||
return new UncategorizedKeyvalueStoreException("Unknown jedis exception", ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws DataAccessException {
|
||||
// return the connection to the pool
|
||||
try {
|
||||
@@ -153,10 +154,12 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Jedis getNativeConnection() {
|
||||
return jedis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
try {
|
||||
return !jedis.isConnected();
|
||||
@@ -165,14 +168,17 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQueueing() {
|
||||
return client.isInMulti();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPipelined() {
|
||||
return (pipeline != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openPipeline() {
|
||||
if (pipeline == null) {
|
||||
pipeline = jedis.pipelined();
|
||||
@@ -180,6 +186,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<Object> closePipeline() {
|
||||
if (pipeline != null) {
|
||||
List execute = pipeline.execute();
|
||||
@@ -190,6 +197,7 @@ public class JedisConnection implements RedisConnection {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> sort(byte[] key, SortParameters params) {
|
||||
|
||||
SortingParams sortParams = JedisUtils.convertSortParams(params);
|
||||
@@ -221,6 +229,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long sort(byte[] key, SortParameters params, byte[] sortKey) {
|
||||
|
||||
SortingParams sortParams = JedisUtils.convertSortParams(params);
|
||||
@@ -252,6 +261,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long dbSize() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -268,6 +278,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void flushDb() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -283,6 +294,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushAll() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -298,6 +310,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bgSave() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -313,6 +326,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bgWriteAof() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -328,6 +342,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -343,6 +358,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getConfig(String param) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -358,6 +374,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties info() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -372,6 +389,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lastSave() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -387,6 +405,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(String param, String value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -403,6 +422,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void resetConfigStats() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -418,6 +438,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -432,6 +453,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] echo(byte[] message) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -447,6 +469,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String ping() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -462,6 +485,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long del(byte[]... keys) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -478,6 +502,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
try {
|
||||
client.discard();
|
||||
@@ -486,6 +511,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> exec() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -498,6 +524,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean exists(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -514,6 +541,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expire(byte[] key, long seconds) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -530,6 +558,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expireAt(byte[] key, long unixTime) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -546,6 +575,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> keys(byte[] pattern) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -562,6 +592,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void multi() {
|
||||
if (isQueueing()) {
|
||||
return;
|
||||
@@ -577,6 +608,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean persist(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -593,6 +625,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean move(byte[] key, int dbIndex) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -609,6 +642,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] randomKey() {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -624,6 +658,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(byte[] oldName, byte[] newName) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -640,6 +675,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean renameNX(byte[] oldName, byte[] newName) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -656,6 +692,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void select(int dbIndex) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -671,6 +708,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long ttl(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -687,6 +725,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType type(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -703,6 +742,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unwatch() {
|
||||
try {
|
||||
jedis.unwatch();
|
||||
@@ -711,6 +751,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(byte[]... keys) {
|
||||
if (isQueueing()) {
|
||||
// ignore (as watch not allowed in multi)
|
||||
@@ -734,6 +775,7 @@ public class JedisConnection implements RedisConnection {
|
||||
// String commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public byte[] get(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -751,6 +793,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -768,6 +811,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] getSet(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -784,6 +828,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long append(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -800,6 +845,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> mGet(byte[]... keys) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -816,6 +862,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mSet(Map<byte[], byte[]> tuples) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -832,6 +879,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mSetNX(Map<byte[], byte[]> tuples) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -848,6 +896,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEx(byte[] key, long time, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -864,6 +913,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean setNX(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -880,6 +930,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getRange(byte[] key, long start, long end) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -896,6 +947,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long decr(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -912,6 +964,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long decrBy(byte[] key, long value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -928,6 +981,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long incr(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -944,6 +998,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long incrBy(byte[] key, long value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -960,6 +1015,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getBit(byte[] key, long offset) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -976,6 +1032,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBit(byte[] key, long offset, boolean value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -992,10 +1049,12 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRange(byte[] key, byte[] value, long start) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long strLen(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1015,6 +1074,7 @@ public class JedisConnection implements RedisConnection {
|
||||
// List commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public Long lPush(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1031,6 +1091,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rPush(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1047,6 +1108,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> bLPop(int timeout, byte[]... keys) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1067,6 +1129,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> bRPop(int timeout, byte[]... keys) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1087,6 +1150,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] lIndex(byte[] key, long index) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1103,6 +1167,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lInsert(byte[] key, Position where, byte[] pivot, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1120,6 +1185,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lLen(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1136,6 +1202,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] lPop(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1152,6 +1219,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> lRange(byte[] key, long start, long end) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1168,6 +1236,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lRem(byte[] key, long count, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1184,6 +1253,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lSet(byte[] key, long index, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1200,6 +1270,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lTrim(byte[] key, long start, long end) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1216,6 +1287,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] rPop(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1232,6 +1304,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] rPopLPush(byte[] srcKey, byte[] dstKey) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1248,6 +1321,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1263,6 +1337,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lPushX(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1278,6 +1353,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rPushX(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1298,6 +1374,7 @@ public class JedisConnection implements RedisConnection {
|
||||
// Set commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public Boolean sAdd(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1314,6 +1391,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long sCard(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1330,6 +1408,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> sDiff(byte[]... keys) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1346,6 +1425,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sDiffStore(byte[] destKey, byte[]... keys) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1362,6 +1442,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> sInter(byte[]... keys) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1378,6 +1459,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sInterStore(byte[] destKey, byte[]... keys) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1394,6 +1476,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sIsMember(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1410,6 +1493,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> sMembers(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1426,6 +1510,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sMove(byte[] srcKey, byte[] destKey, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1442,6 +1527,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] sPop(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1458,6 +1544,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] sRandMember(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1474,6 +1561,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sRem(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1490,6 +1578,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> sUnion(byte[]... keys) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1506,6 +1595,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sUnionStore(byte[] destKey, byte[]... keys) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1526,6 +1616,7 @@ public class JedisConnection implements RedisConnection {
|
||||
// ZSet commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public Boolean zAdd(byte[] key, double score, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1542,6 +1633,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zCard(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1558,6 +1650,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zCount(byte[] key, double min, double max) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1573,6 +1666,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double zIncrBy(byte[] key, double increment, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1589,6 +1683,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zInterStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1606,6 +1701,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zInterStore(byte[] destKey, byte[]... sets) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1621,6 +1717,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRange(byte[] key, long start, long end) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1637,6 +1734,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRangeWithScore(byte[] key, long start, long end) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1653,6 +1751,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRangeByScore(byte[] key, double min, double max) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1668,6 +1767,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRangeByScoreWithScore(byte[] key, double min, double max) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1683,6 +1783,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRevRangeWithScore(byte[] key, long start, long end) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1698,6 +1799,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRangeByScore(byte[] key, double min, double max, long offset, long count) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1713,6 +1815,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRangeByScoreWithScore(byte[] key, double min, double max, long offset, long count) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1728,6 +1831,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRank(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1744,6 +1848,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean zRem(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1760,6 +1865,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRemRange(byte[] key, long start, long end) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1775,6 +1881,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRemRangeByScore(byte[] key, double min, double max) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1790,6 +1897,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRevRange(byte[] key, long start, long end) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1806,6 +1914,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRevRank(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1822,6 +1931,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double zScore(byte[] key, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1838,6 +1948,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zUnionStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1855,6 +1966,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zUnionStore(byte[] destKey, byte[]... sets) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1874,6 +1986,7 @@ public class JedisConnection implements RedisConnection {
|
||||
// Hash commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public Boolean hSet(byte[] key, byte[] field, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1890,6 +2003,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hSetNX(byte[] key, byte[] field, byte[] value) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1906,6 +2020,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hDel(byte[] key, byte[] field) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1922,6 +2037,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hExists(byte[] key, byte[] field) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1938,6 +2054,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] hGet(byte[] key, byte[] field) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1954,6 +2071,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<byte[], byte[]> hGetAll(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1970,6 +2088,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long hIncrBy(byte[] key, byte[] field, long delta) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1986,6 +2105,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> hKeys(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -2002,6 +2122,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long hLen(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -2018,6 +2139,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> hMGet(byte[] key, byte[]... fields) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -2034,6 +2156,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hMSet(byte[] key, Map<byte[], byte[]> tuple) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -2050,6 +2173,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> hVals(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -2070,6 +2194,7 @@ public class JedisConnection implements RedisConnection {
|
||||
//
|
||||
// Pub/Sub functionality
|
||||
//
|
||||
@Override
|
||||
public Long publish(byte[] channel, byte[] message) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -2084,14 +2209,17 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subscription getSubscription() {
|
||||
return subscription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubscribed() {
|
||||
return (subscription != null && subscription.isAlive());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pSubscribe(MessageListener listener, byte[]... patterns) {
|
||||
if (isSubscribed()) {
|
||||
throw new RedisSubscribedConnectionException(
|
||||
@@ -2116,6 +2244,7 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(MessageListener listener, byte[]... channels) {
|
||||
if (isSubscribed()) {
|
||||
throw new RedisSubscribedConnectionException(
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.DataAccessResourceFailureException;
|
||||
import org.springframework.data.keyvalue.redis.connection.RedisConnection;
|
||||
import org.springframework.data.keyvalue.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -149,6 +150,7 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
|
||||
null, dbIndex)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
|
||||
return JedisUtils.convertJedisAccessException(ex);
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ public class JredisConnection implements RedisConnection {
|
||||
return new UncategorizedKeyvalueStoreException("Unknown JRedis exception", ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws RedisSystemException {
|
||||
isClosed = true;
|
||||
|
||||
@@ -88,30 +89,37 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JRedis getNativeConnection() {
|
||||
return jredis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return isClosed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQueueing() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPipelined() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openPipeline() {
|
||||
throw new UnsupportedOperationException("Pipelining not supported by JRedis");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> closePipeline() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> sort(byte[] key, SortParameters params) {
|
||||
Sort sort = jredis.sort(JredisUtils.decode(key));
|
||||
JredisUtils.applySortingParams(sort, params, null);
|
||||
@@ -122,6 +130,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long sort(byte[] key, SortParameters params, byte[] storeKey) {
|
||||
Sort sort = jredis.sort(JredisUtils.decode(key));
|
||||
JredisUtils.applySortingParams(sort, params, null);
|
||||
@@ -132,6 +141,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long dbSize() {
|
||||
try {
|
||||
return jredis.dbsize();
|
||||
@@ -140,6 +150,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushDb() {
|
||||
try {
|
||||
jredis.flushdb();
|
||||
@@ -148,6 +159,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushAll() {
|
||||
try {
|
||||
jredis.flushall();
|
||||
@@ -156,6 +168,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] echo(byte[] message) {
|
||||
try {
|
||||
return jredis.echo(message);
|
||||
@@ -164,6 +177,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String ping() {
|
||||
try {
|
||||
jredis.ping();
|
||||
@@ -173,6 +187,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bgSave() {
|
||||
try {
|
||||
jredis.bgsave();
|
||||
@@ -181,6 +196,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bgWriteAof() {
|
||||
try {
|
||||
jredis.bgrewriteaof();
|
||||
@@ -189,6 +205,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
try {
|
||||
jredis.save();
|
||||
@@ -197,10 +214,12 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getConfig(String pattern) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties info() {
|
||||
try {
|
||||
return JredisUtils.info(jredis.info());
|
||||
@@ -209,6 +228,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lastSave() {
|
||||
try {
|
||||
return jredis.lastsave();
|
||||
@@ -217,18 +237,22 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(String param, String value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetConfigStats() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long del(byte[]... keys) {
|
||||
try {
|
||||
return jredis.del(JredisUtils.decodeMultiple(keys));
|
||||
@@ -237,6 +261,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
try {
|
||||
jredis.discard();
|
||||
@@ -245,10 +270,12 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> exec() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean exists(byte[] key) {
|
||||
try {
|
||||
return jredis.exists(JredisUtils.decode(key));
|
||||
@@ -257,6 +284,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expire(byte[] key, long seconds) {
|
||||
try {
|
||||
return jredis.expire(JredisUtils.decode(key), (int) seconds);
|
||||
@@ -265,6 +293,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expireAt(byte[] key, long unixTime) {
|
||||
try {
|
||||
return jredis.expireat(JredisUtils.decode(key), unixTime);
|
||||
@@ -273,6 +302,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> keys(byte[] pattern) {
|
||||
try {
|
||||
return JredisUtils.convertToSet(jredis.keys(JredisUtils.decode(pattern)));
|
||||
@@ -281,15 +311,18 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void multi() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean persist(byte[] key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean move(byte[] key, int dbIndex) {
|
||||
try {
|
||||
return jredis.move(JredisUtils.decode(key), dbIndex);
|
||||
@@ -298,6 +331,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] randomKey() {
|
||||
try {
|
||||
return JredisUtils.encode(jredis.randomkey());
|
||||
@@ -306,6 +340,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(byte[] oldName, byte[] newName) {
|
||||
try {
|
||||
jredis.rename(JredisUtils.decode(oldName), JredisUtils.decode(newName));
|
||||
@@ -314,6 +349,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean renameNX(byte[] oldName, byte[] newName) {
|
||||
try {
|
||||
return jredis.renamenx(JredisUtils.decode(oldName), JredisUtils.decode(newName));
|
||||
@@ -322,10 +358,12 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void select(int dbIndex) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long ttl(byte[] key) {
|
||||
try {
|
||||
return jredis.ttl(JredisUtils.decode(key));
|
||||
@@ -334,6 +372,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType type(byte[] key) {
|
||||
try {
|
||||
return JredisUtils.convertDataType(jredis.type(JredisUtils.decode(key)));
|
||||
@@ -342,10 +381,12 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unwatch() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(byte[]... keys) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -354,6 +395,7 @@ public class JredisConnection implements RedisConnection {
|
||||
// String operations
|
||||
//
|
||||
|
||||
@Override
|
||||
public byte[] get(byte[] key) {
|
||||
try {
|
||||
return jredis.get(JredisUtils.decode(key));
|
||||
@@ -362,6 +404,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(byte[] key, byte[] value) {
|
||||
try {
|
||||
jredis.set(JredisUtils.decode(key), value);
|
||||
@@ -370,6 +413,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getSet(byte[] key, byte[] value) {
|
||||
try {
|
||||
return jredis.getset(JredisUtils.decode(key), value);
|
||||
@@ -378,6 +422,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long append(byte[] key, byte[] value) {
|
||||
try {
|
||||
return jredis.append(JredisUtils.decode(key), value);
|
||||
@@ -386,6 +431,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> mGet(byte[]... keys) {
|
||||
try {
|
||||
return jredis.mget(JredisUtils.decodeMultiple(keys));
|
||||
@@ -394,6 +440,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mSet(Map<byte[], byte[]> tuple) {
|
||||
try {
|
||||
jredis.mset(JredisUtils.decodeMap(tuple));
|
||||
@@ -402,6 +449,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mSetNX(Map<byte[], byte[]> tuple) {
|
||||
try {
|
||||
jredis.msetnx(JredisUtils.decodeMap(tuple));
|
||||
@@ -410,10 +458,12 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEx(byte[] key, long seconds, byte[] value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean setNX(byte[] key, byte[] value) {
|
||||
try {
|
||||
return jredis.setnx(JredisUtils.decode(key), value);
|
||||
@@ -422,6 +472,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getRange(byte[] key, long start, long end) {
|
||||
try {
|
||||
return jredis.substr(JredisUtils.decode(key), start, end);
|
||||
@@ -430,6 +481,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long decr(byte[] key) {
|
||||
try {
|
||||
return jredis.decr(JredisUtils.decode(key));
|
||||
@@ -438,6 +490,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long decrBy(byte[] key, long value) {
|
||||
try {
|
||||
return jredis.decrby(JredisUtils.decode(key), (int) value);
|
||||
@@ -446,6 +499,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long incr(byte[] key) {
|
||||
try {
|
||||
return jredis.incr(JredisUtils.decode(key));
|
||||
@@ -454,6 +508,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long incrBy(byte[] key, long value) {
|
||||
try {
|
||||
return jredis.incrby(JredisUtils.decode(key), (int) value);
|
||||
@@ -462,18 +517,22 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getBit(byte[] key, long offset) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBit(byte[] key, long offset, boolean value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRange(byte[] key, byte[] value, long start) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long strLen(byte[] key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -482,14 +541,17 @@ public class JredisConnection implements RedisConnection {
|
||||
// List commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public List<byte[]> bLPop(int timeout, byte[]... keys) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> bRPop(int timeout, byte[]... keys) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] lIndex(byte[] key, long index) {
|
||||
try {
|
||||
return jredis.lindex(JredisUtils.decode(key), index);
|
||||
@@ -498,6 +560,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lLen(byte[] key) {
|
||||
try {
|
||||
return jredis.llen(JredisUtils.decode(key));
|
||||
@@ -506,6 +569,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] lPop(byte[] key) {
|
||||
try {
|
||||
return jredis.lpop(JredisUtils.decode(key));
|
||||
@@ -514,6 +578,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lPush(byte[] key, byte[] value) {
|
||||
try {
|
||||
jredis.lpush(JredisUtils.decode(key), value);
|
||||
@@ -523,6 +588,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> lRange(byte[] key, long start, long end) {
|
||||
try {
|
||||
List<byte[]> lrange = jredis.lrange(JredisUtils.decode(key), start, end);
|
||||
@@ -533,6 +599,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lRem(byte[] key, long count, byte[] value) {
|
||||
try {
|
||||
return jredis.lrem(JredisUtils.decode(key), value, (int) count);
|
||||
@@ -541,6 +608,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lSet(byte[] key, long index, byte[] value) {
|
||||
try {
|
||||
jredis.lset(JredisUtils.decode(key), index, value);
|
||||
@@ -549,6 +617,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lTrim(byte[] key, long start, long end) {
|
||||
try {
|
||||
jredis.ltrim(JredisUtils.decode(key), start, end);
|
||||
@@ -557,6 +626,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] rPop(byte[] key) {
|
||||
try {
|
||||
return jredis.rpop(JredisUtils.decode(key));
|
||||
@@ -565,6 +635,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] rPopLPush(byte[] srcKey, byte[] dstKey) {
|
||||
try {
|
||||
return jredis.rpoplpush(JredisUtils.decode(srcKey), JredisUtils.decode(dstKey));
|
||||
@@ -573,6 +644,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rPush(byte[] key, byte[] value) {
|
||||
try {
|
||||
jredis.rpush(JredisUtils.decode(key), value);
|
||||
@@ -582,18 +654,22 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lInsert(byte[] key, Position where, byte[] pivot, byte[] value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lPushX(byte[] key, byte[] value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rPushX(byte[] key, byte[] value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -603,6 +679,7 @@ public class JredisConnection implements RedisConnection {
|
||||
// Set commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public Boolean sAdd(byte[] key, byte[] value) {
|
||||
try {
|
||||
return jredis.sadd(JredisUtils.decode(key), value);
|
||||
@@ -611,6 +688,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long sCard(byte[] key) {
|
||||
try {
|
||||
return jredis.scard(JredisUtils.decode(key));
|
||||
@@ -619,6 +697,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> sDiff(byte[]... keys) {
|
||||
String destKey = JredisUtils.decode(keys[0]);
|
||||
String[] sets = JredisUtils.decodeMultiple(Arrays.copyOfRange(keys, 1, keys.length));
|
||||
@@ -631,6 +710,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sDiffStore(byte[] destKey, byte[]... keys) {
|
||||
String destSet = JredisUtils.decode(destKey);
|
||||
String[] sets = JredisUtils.decodeMultiple(keys);
|
||||
@@ -642,6 +722,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> sInter(byte[]... keys) {
|
||||
String set1 = JredisUtils.decode(keys[0]);
|
||||
String[] sets = JredisUtils.decodeMultiple(Arrays.copyOfRange(keys, 1, keys.length));
|
||||
@@ -654,6 +735,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sInterStore(byte[] destKey, byte[]... keys) {
|
||||
String destSet = JredisUtils.decode(destKey);
|
||||
String[] sets = JredisUtils.decodeMultiple(keys);
|
||||
@@ -665,6 +747,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sIsMember(byte[] key, byte[] value) {
|
||||
try {
|
||||
return jredis.sismember(JredisUtils.decode(key), value);
|
||||
@@ -673,6 +756,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> sMembers(byte[] key) {
|
||||
try {
|
||||
return new LinkedHashSet<byte[]>(jredis.smembers(JredisUtils.decode(key)));
|
||||
@@ -681,6 +765,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sMove(byte[] srcKey, byte[] destKey, byte[] value) {
|
||||
try {
|
||||
return jredis.smove(JredisUtils.decode(srcKey), JredisUtils.decode(destKey), value);
|
||||
@@ -689,6 +774,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] sPop(byte[] key) {
|
||||
try {
|
||||
return jredis.spop(JredisUtils.decode(key));
|
||||
@@ -697,6 +783,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] sRandMember(byte[] key) {
|
||||
try {
|
||||
return jredis.srandmember(JredisUtils.decode(key));
|
||||
@@ -705,6 +792,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sRem(byte[] key, byte[] value) {
|
||||
try {
|
||||
return jredis.srem(JredisUtils.decode(key), value);
|
||||
@@ -713,6 +801,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> sUnion(byte[]... keys) {
|
||||
String set1 = JredisUtils.decode(keys[0]);
|
||||
String[] sets = JredisUtils.decodeMultiple(Arrays.copyOfRange(keys, 1, keys.length));
|
||||
@@ -724,6 +813,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sUnionStore(byte[] destKey, byte[]... keys) {
|
||||
String destSet = JredisUtils.decode(destKey);
|
||||
String[] sets = JredisUtils.decodeMultiple(keys);
|
||||
@@ -740,6 +830,7 @@ public class JredisConnection implements RedisConnection {
|
||||
// ZSet commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public Boolean zAdd(byte[] key, double score, byte[] value) {
|
||||
try {
|
||||
return jredis.zadd(JredisUtils.decode(key), score, value);
|
||||
@@ -748,6 +839,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zCard(byte[] key) {
|
||||
try {
|
||||
return jredis.zcard(JredisUtils.decode(key));
|
||||
@@ -756,6 +848,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zCount(byte[] key, double min, double max) {
|
||||
try {
|
||||
return jredis.zcount(JredisUtils.decode(key), min, max);
|
||||
@@ -764,6 +857,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double zIncrBy(byte[] key, double increment, byte[] value) {
|
||||
try {
|
||||
return jredis.zincrby(JredisUtils.decode(key), increment, value);
|
||||
@@ -772,14 +866,17 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zInterStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zInterStore(byte[] destKey, byte[]... sets) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRange(byte[] key, long start, long end) {
|
||||
try {
|
||||
return new LinkedHashSet<byte[]>(jredis.zrange(JredisUtils.decode(key), start, end));
|
||||
@@ -788,11 +885,13 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRangeWithScore(byte[] key, long start, long end) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRangeByScore(byte[] key, double min, double max) {
|
||||
try {
|
||||
return new LinkedHashSet<byte[]>(jredis.zrangebyscore(JredisUtils.decode(key), min, max));
|
||||
@@ -801,18 +900,22 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRangeByScoreWithScore(byte[] key, double min, double max) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRangeByScore(byte[] key, double min, double max, long offset, long count) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRangeByScoreWithScore(byte[] key, double min, double max, long offset, long count) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRank(byte[] key, byte[] value) {
|
||||
try {
|
||||
return jredis.zrank(JredisUtils.decode(key), value);
|
||||
@@ -821,6 +924,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean zRem(byte[] key, byte[] value) {
|
||||
try {
|
||||
return jredis.zrem(JredisUtils.decode(key), value);
|
||||
@@ -829,6 +933,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRemRange(byte[] key, long start, long end) {
|
||||
try {
|
||||
return jredis.zremrangebyrank(JredisUtils.decode(key), start, end);
|
||||
@@ -837,6 +942,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRemRangeByScore(byte[] key, double min, double max) {
|
||||
try {
|
||||
return jredis.zremrangebyscore(JredisUtils.decode(key), min, max);
|
||||
@@ -845,6 +951,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRevRange(byte[] key, long start, long end) {
|
||||
try {
|
||||
return new LinkedHashSet<byte[]>(jredis.zrevrange(JredisUtils.decode(key), start, end));
|
||||
@@ -853,10 +960,12 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRevRangeWithScore(byte[] key, long start, long end) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRevRank(byte[] key, byte[] value) {
|
||||
try {
|
||||
return jredis.zrevrank(JredisUtils.decode(key), value);
|
||||
@@ -865,6 +974,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double zScore(byte[] key, byte[] value) {
|
||||
try {
|
||||
return jredis.zscore(JredisUtils.decode(key), value);
|
||||
@@ -878,14 +988,17 @@ public class JredisConnection implements RedisConnection {
|
||||
// Hash commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public Long zUnionStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zUnionStore(byte[] destKey, byte[]... sets) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hDel(byte[] key, byte[] field) {
|
||||
try {
|
||||
return jredis.hdel(JredisUtils.decode(key), JredisUtils.decode(field));
|
||||
@@ -894,6 +1007,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hExists(byte[] key, byte[] field) {
|
||||
try {
|
||||
return jredis.hexists(JredisUtils.decode(key), JredisUtils.decode(field));
|
||||
@@ -902,6 +1016,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] hGet(byte[] key, byte[] field) {
|
||||
try {
|
||||
return jredis.hget(JredisUtils.decode(key), JredisUtils.decode(field));
|
||||
@@ -910,6 +1025,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<byte[], byte[]> hGetAll(byte[] key) {
|
||||
try {
|
||||
return JredisUtils.encodeMap(jredis.hgetall(JredisUtils.decode(key)));
|
||||
@@ -918,10 +1034,12 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long hIncrBy(byte[] key, byte[] field, long delta) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> hKeys(byte[] key) {
|
||||
try {
|
||||
return new LinkedHashSet<byte[]>(JredisUtils.convertToSet(jredis.hkeys(JredisUtils.decode(key))));
|
||||
@@ -930,6 +1048,7 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long hLen(byte[] key) {
|
||||
try {
|
||||
return jredis.hlen(JredisUtils.decode(key));
|
||||
@@ -938,14 +1057,17 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> hMGet(byte[] key, byte[]... fields) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hMSet(byte[] key, Map<byte[], byte[]> values) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hSet(byte[] key, byte[] field, byte[] value) {
|
||||
try {
|
||||
return jredis.hset(JredisUtils.decode(key), JredisUtils.decode(field), value);
|
||||
@@ -954,10 +1076,12 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hSetNX(byte[] key, byte[] field, byte[] value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> hVals(byte[] key) {
|
||||
try {
|
||||
return jredis.hvals(JredisUtils.decode(key));
|
||||
@@ -970,22 +1094,27 @@ public class JredisConnection implements RedisConnection {
|
||||
// PubSub commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public Subscription getSubscription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubscribed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pSubscribe(MessageListener listener, byte[]... patterns) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long publish(byte[] channel, byte[] message) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(MessageListener listener, byte[]... channels) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ public class JredisConnectionFactory implements InitializingBean, DisposableBean
|
||||
this.connectionSpec = connectionSpec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
if (connectionSpec == null) {
|
||||
Assert.hasText(hostName);
|
||||
@@ -94,6 +95,7 @@ public class JredisConnectionFactory implements InitializingBean, DisposableBean
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (usePool && pool != null) {
|
||||
pool.quit();
|
||||
@@ -102,6 +104,7 @@ public class JredisConnectionFactory implements InitializingBean, DisposableBean
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RedisConnection getConnection() {
|
||||
return postProcessConnection(new JredisConnection((usePool ? pool : new JRedisClient(connectionSpec))));
|
||||
}
|
||||
@@ -119,6 +122,7 @@ public class JredisConnectionFactory implements InitializingBean, DisposableBean
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
|
||||
if (ex instanceof ClientRuntimeException) {
|
||||
return JredisUtils.convertJredisAccessException((ClientRuntimeException) ex);
|
||||
|
||||
@@ -76,6 +76,7 @@ public class RjcConnection implements RedisConnection {
|
||||
return new UncategorizedKeyvalueStoreException("Unknown rjc exception", ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws DataAccessException {
|
||||
isClosed = true;
|
||||
|
||||
@@ -88,22 +89,27 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return isClosed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Session getNativeConnection() {
|
||||
return session;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQueueing() {
|
||||
return client.isInMulti();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPipelined() {
|
||||
return (pipeline != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openPipeline() {
|
||||
if (pipeline == null) {
|
||||
pipeline = client;
|
||||
@@ -111,6 +117,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<Object> closePipeline() {
|
||||
if (pipeline != null) {
|
||||
List execute = client.getAll();
|
||||
@@ -121,6 +128,7 @@ public class RjcConnection implements RedisConnection {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> sort(byte[] key, SortParameters params) {
|
||||
|
||||
SortingParams sortParams = RjcUtils.convertSortParams(params);
|
||||
@@ -144,6 +152,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long sort(byte[] key, SortParameters params, byte[] sortKey) {
|
||||
|
||||
SortingParams sortParams = RjcUtils.convertSortParams(params);
|
||||
@@ -168,6 +177,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long dbSize() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -181,6 +191,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void flushDb() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -193,6 +204,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushAll() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -205,6 +217,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bgSave() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -217,6 +230,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bgWriteAof() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -229,6 +243,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -241,6 +256,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getConfig(String param) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -253,6 +269,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties info() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -265,6 +282,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lastSave() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -277,6 +295,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(String param, String value) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -290,6 +309,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void resetConfigStats() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -303,6 +323,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -315,6 +336,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] echo(byte[] message) {
|
||||
String stringMsg = RjcUtils.decode(message);
|
||||
try {
|
||||
@@ -328,6 +350,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String ping() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -339,6 +362,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long del(byte[]... keys) {
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(keys);
|
||||
|
||||
@@ -353,6 +377,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -366,6 +391,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> exec() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -378,6 +404,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean exists(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -392,6 +419,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expire(byte[] key, long seconds) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -406,6 +434,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expireAt(byte[] key, long unixTime) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -420,6 +449,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> keys(byte[] pattern) {
|
||||
String stringKey = RjcUtils.decode(pattern);
|
||||
|
||||
@@ -434,6 +464,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void multi() {
|
||||
if (isQueueing()) {
|
||||
return;
|
||||
@@ -449,6 +480,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean persist(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -463,6 +495,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean move(byte[] key, int dbIndex) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -477,6 +510,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] randomKey() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -489,6 +523,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(byte[] oldName, byte[] newName) {
|
||||
String stringOldKey = RjcUtils.decode(oldName);
|
||||
String stringNewKey = RjcUtils.decode(newName);
|
||||
@@ -504,6 +539,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean renameNX(byte[] oldName, byte[] newName) {
|
||||
String stringOldKey = RjcUtils.decode(oldName);
|
||||
String stringNewKey = RjcUtils.decode(newName);
|
||||
@@ -519,6 +555,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void select(int dbIndex) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -531,6 +568,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long ttl(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -545,6 +583,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType type(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -559,6 +598,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unwatch() {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
@@ -572,6 +612,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(byte[]... keys) {
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(keys);
|
||||
|
||||
@@ -595,6 +636,7 @@ public class RjcConnection implements RedisConnection {
|
||||
// String commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public byte[] get(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -610,6 +652,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -626,6 +669,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] getSet(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -641,6 +685,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long append(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -656,6 +701,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> mGet(byte[]... keys) {
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(keys);
|
||||
|
||||
@@ -670,6 +716,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mSet(Map<byte[], byte[]> tuples) {
|
||||
String[] decodeMap = RjcUtils.flatten(tuples);
|
||||
|
||||
@@ -684,6 +731,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mSetNX(Map<byte[], byte[]> tuples) {
|
||||
String[] decodeMap = RjcUtils.flatten(tuples);
|
||||
|
||||
@@ -699,6 +747,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEx(byte[] key, long time, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -714,6 +763,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean setNX(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -729,6 +779,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getRange(byte[] key, long start, long end) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -743,6 +794,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long decr(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
try {
|
||||
@@ -757,6 +809,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long decrBy(byte[] key, long value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
try {
|
||||
@@ -771,6 +824,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long incr(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -786,6 +840,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long incrBy(byte[] key, long value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -801,6 +856,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getBit(byte[] key, long offset) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -815,6 +871,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBit(byte[] key, long offset, boolean value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -829,6 +886,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRange(byte[] key, byte[] value, long offset) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -844,6 +902,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long strLen(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -862,6 +921,7 @@ public class RjcConnection implements RedisConnection {
|
||||
// List commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public Long lPush(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -877,6 +937,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rPush(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -893,6 +954,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> bLPop(int timeout, byte[]... keys) {
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(keys);
|
||||
|
||||
@@ -907,6 +969,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> bRPop(int timeout, byte[]... keys) {
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(keys);
|
||||
|
||||
@@ -921,6 +984,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] lIndex(byte[] key, long index) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -936,6 +1000,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lInsert(byte[] key, Position where, byte[] pivot, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -953,6 +1018,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lLen(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -968,6 +1034,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] lPop(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -983,6 +1050,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> lRange(byte[] key, long start, long end) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -998,6 +1066,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lRem(byte[] key, long count, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -1014,6 +1083,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lSet(byte[] key, long index, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -1029,6 +1099,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lTrim(byte[] key, long start, long end) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -1044,6 +1115,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] rPop(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -1059,6 +1131,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] rPopLPush(byte[] srcKey, byte[] dstKey) {
|
||||
String stringKey = RjcUtils.decode(srcKey);
|
||||
String stringDest = RjcUtils.decode(dstKey);
|
||||
@@ -1075,6 +1148,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey) {
|
||||
String stringKey = RjcUtils.decode(srcKey);
|
||||
String stringDest = RjcUtils.decode(dstKey);
|
||||
@@ -1090,6 +1164,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long lPushX(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -1104,6 +1179,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rPushX(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -1123,6 +1199,7 @@ public class RjcConnection implements RedisConnection {
|
||||
// Set commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public Boolean sAdd(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -1139,6 +1216,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long sCard(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -1154,6 +1232,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> sDiff(byte[]... keys) {
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(keys);
|
||||
|
||||
@@ -1169,6 +1248,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sDiffStore(byte[] destKey, byte[]... keys) {
|
||||
String stringKey = RjcUtils.decode(destKey);
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(keys);
|
||||
@@ -1185,6 +1265,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> sInter(byte[]... keys) {
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(keys);
|
||||
try {
|
||||
@@ -1199,6 +1280,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sInterStore(byte[] destKey, byte[]... keys) {
|
||||
String stringKey = RjcUtils.decode(destKey);
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(keys);
|
||||
@@ -1214,6 +1296,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sIsMember(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -1230,6 +1313,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> sMembers(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
try {
|
||||
@@ -1244,6 +1328,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sMove(byte[] srcKey, byte[] destKey, byte[] value) {
|
||||
String stringSrc = RjcUtils.decode(srcKey);
|
||||
String stringDest = RjcUtils.decode(destKey);
|
||||
@@ -1261,6 +1346,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] sPop(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
try {
|
||||
@@ -1275,6 +1361,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] sRandMember(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
try {
|
||||
@@ -1289,6 +1376,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sRem(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -1305,6 +1393,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> sUnion(byte[]... keys) {
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(keys);
|
||||
|
||||
@@ -1320,6 +1409,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sUnionStore(byte[] destKey, byte[]... keys) {
|
||||
String stringKey = RjcUtils.decode(destKey);
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(keys);
|
||||
@@ -1340,6 +1430,7 @@ public class RjcConnection implements RedisConnection {
|
||||
// ZSet commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public Boolean zAdd(byte[] key, double score, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -1355,6 +1446,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zCard(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -1369,6 +1461,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zCount(byte[] key, double min, double max) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
try {
|
||||
@@ -1383,6 +1476,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double zIncrBy(byte[] key, double increment, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -1398,6 +1492,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zInterStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
|
||||
String stringKey = RjcUtils.decode(destKey);
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(sets);
|
||||
@@ -1415,6 +1510,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zInterStore(byte[] destKey, byte[]... sets) {
|
||||
String stringKey = RjcUtils.decode(destKey);
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(sets);
|
||||
@@ -1430,6 +1526,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRange(byte[] key, long start, long end) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
try {
|
||||
@@ -1444,6 +1541,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRangeWithScore(byte[] key, long start, long end) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
try {
|
||||
@@ -1458,6 +1556,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRangeByScore(byte[] key, double min, double max) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String minString = Double.toString(min);
|
||||
@@ -1474,6 +1573,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRangeByScoreWithScore(byte[] key, double min, double max) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String minString = Double.toString(min);
|
||||
@@ -1490,6 +1590,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRevRangeWithScore(byte[] key, long start, long end) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String minString = Long.toString(start);
|
||||
@@ -1507,6 +1608,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRangeByScore(byte[] key, double min, double max, long offset, long count) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String minString = Double.toString(min);
|
||||
@@ -1524,6 +1626,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRangeByScoreWithScore(byte[] key, double min, double max, long offset, long count) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String minString = Double.toString(min);
|
||||
@@ -1541,6 +1644,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRank(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -1556,6 +1660,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean zRem(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -1571,6 +1676,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRemRange(byte[] key, long start, long end) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
try {
|
||||
@@ -1584,6 +1690,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRemRangeByScore(byte[] key, double min, double max) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String minString = Double.toString(min);
|
||||
@@ -1600,6 +1707,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRevRange(byte[] key, long start, long end) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
try {
|
||||
@@ -1614,6 +1722,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zRevRank(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -1629,6 +1738,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double zScore(byte[] key, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringValue = RjcUtils.decode(value);
|
||||
@@ -1644,6 +1754,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zUnionStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
|
||||
String stringKey = RjcUtils.decode(destKey);
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(destKey);
|
||||
@@ -1661,6 +1772,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long zUnionStore(byte[] destKey, byte[]... sets) {
|
||||
String stringKey = RjcUtils.decode(destKey);
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(sets);
|
||||
@@ -1680,6 +1792,7 @@ public class RjcConnection implements RedisConnection {
|
||||
// Hash commands
|
||||
//
|
||||
|
||||
@Override
|
||||
public Boolean hSet(byte[] key, byte[] field, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringField = RjcUtils.decode(field);
|
||||
@@ -1696,6 +1809,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hSetNX(byte[] key, byte[] field, byte[] value) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringField = RjcUtils.decode(field);
|
||||
@@ -1712,6 +1826,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hDel(byte[] key, byte[] field) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringField = RjcUtils.decode(field);
|
||||
@@ -1727,6 +1842,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hExists(byte[] key, byte[] field) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringField = RjcUtils.decode(field);
|
||||
@@ -1742,6 +1858,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] hGet(byte[] key, byte[] field) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringField = RjcUtils.decode(field);
|
||||
@@ -1757,6 +1874,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<byte[], byte[]> hGetAll(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
|
||||
@@ -1771,6 +1889,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long hIncrBy(byte[] key, byte[] field, long delta) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String stringField = RjcUtils.decode(field);
|
||||
@@ -1786,6 +1905,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> hKeys(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
try {
|
||||
@@ -1799,6 +1919,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long hLen(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
try {
|
||||
@@ -1812,6 +1933,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> hMGet(byte[] key, byte[]... fields) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
String[] stringKeys = RjcUtils.decodeMultiple(fields);
|
||||
@@ -1827,6 +1949,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hMSet(byte[] key, Map<byte[], byte[]> tuple) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
Map<String, String> stringTuple = RjcUtils.decodeMap(tuple);
|
||||
@@ -1842,6 +1965,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> hVals(byte[] key) {
|
||||
String stringKey = RjcUtils.decode(key);
|
||||
try {
|
||||
@@ -1860,6 +1984,7 @@ public class RjcConnection implements RedisConnection {
|
||||
//
|
||||
// Pub/Sub functionality
|
||||
//
|
||||
@Override
|
||||
public Long publish(byte[] channel, byte[] message) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
@@ -1874,14 +1999,17 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Subscription getSubscription() {
|
||||
return subscription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubscribed() {
|
||||
return (subscription != null && subscription.isAlive());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pSubscribe(MessageListener listener, byte[]... patterns) {
|
||||
if (isSubscribed()) {
|
||||
throw new RedisSubscribedConnectionException(
|
||||
@@ -1905,6 +2033,7 @@ public class RjcConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(MessageListener listener, byte[]... channels) {
|
||||
if (isSubscribed()) {
|
||||
throw new RedisSubscribedConnectionException(
|
||||
|
||||
@@ -85,6 +85,7 @@ public class RjcConnectionFactory implements InitializingBean, DisposableBean, R
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisConnection getConnection() {
|
||||
return postProcessConnection(new RjcConnection(dataSource.getConnection(), dbIndex));
|
||||
}
|
||||
@@ -101,6 +102,7 @@ public class RjcConnectionFactory implements InitializingBean, DisposableBean, R
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
|
||||
return RjcUtils.convertRjcAccessException(ex);
|
||||
}
|
||||
|
||||
@@ -32,10 +32,12 @@ class RjcMessageListener implements MessageListener, PMessageListener {
|
||||
this.listener = messageListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(String channel, String message) {
|
||||
listener.onMessage(new DefaultMessage(RjcUtils.encode(channel), RjcUtils.encode(message)), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(String pattern, String channel, String message) {
|
||||
listener.onMessage(new DefaultMessage(RjcUtils.encode(channel), RjcUtils.encode(message)),
|
||||
RjcUtils.encode(pattern));
|
||||
|
||||
@@ -31,6 +31,7 @@ class SingleDataSource implements DataSource {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisConnection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
@@ -98,22 +98,26 @@ public abstract class AbstractSubscription implements Subscription {
|
||||
*/
|
||||
protected abstract void doClose();
|
||||
|
||||
@Override
|
||||
public MessageListener getListener() {
|
||||
return listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<byte[]> getChannels() {
|
||||
synchronized (channels) {
|
||||
return clone(channels);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<byte[]> getPatterns() {
|
||||
synchronized (patterns) {
|
||||
return clone(patterns);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pSubscribe(byte[]... patterns) {
|
||||
checkPulse();
|
||||
|
||||
@@ -126,11 +130,13 @@ public abstract class AbstractSubscription implements Subscription {
|
||||
doPsubscribe(patterns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pUnsubscribe() {
|
||||
pUnsubscribe((byte[][]) null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void subscribe(byte[]... channels) {
|
||||
checkPulse();
|
||||
|
||||
@@ -143,10 +149,12 @@ public abstract class AbstractSubscription implements Subscription {
|
||||
doSubscribe(channels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribe() {
|
||||
unsubscribe((byte[][]) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pUnsubscribe(byte[]... patts) {
|
||||
if (!isAlive()) {
|
||||
return;
|
||||
@@ -176,6 +184,7 @@ public abstract class AbstractSubscription implements Subscription {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribe(byte[]... chans) {
|
||||
if (!isAlive()) {
|
||||
return;
|
||||
@@ -205,6 +214,7 @@ public abstract class AbstractSubscription implements Subscription {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return alive.get();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ abstract class AbstractOperations<K, V> {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final V doInRedis(RedisConnection connection) {
|
||||
byte[] result = inRedis(rawKey(key), connection);
|
||||
return deserializeValue(result);
|
||||
|
||||
@@ -41,58 +41,72 @@ class DefaultBoundHashOperations<H, HK, HV> extends DefaultBoundKeyOperations<H>
|
||||
this.ops = operations.opsForHash();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Object key) {
|
||||
ops.delete(getKey(), key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HV get(Object key) {
|
||||
return ops.get(getKey(), key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<HV> multiGet(Collection<HK> hashKeys) {
|
||||
return ops.multiGet(getKey(), hashKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisOperations<H, ?> getOperations() {
|
||||
return ops.getOperations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasKey(Object key) {
|
||||
return ops.hasKey(getKey(), key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long increment(HK key, long delta) {
|
||||
return ops.increment(getKey(), key, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<HK> keys() {
|
||||
return ops.keys(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size() {
|
||||
return ops.size(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends HK, ? extends HV> m) {
|
||||
ops.putAll(getKey(), m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(HK key, HV value) {
|
||||
ops.put(getKey(), key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean putIfAbsent(HK key, HV value) {
|
||||
return ops.putIfAbsent(getKey(), key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<HV> values() {
|
||||
return ops.values(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<HK, HV> entries() {
|
||||
return ops.entries(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getType() {
|
||||
return DataType.HASH;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ abstract class DefaultBoundKeyOperations<K> implements BoundKeyOperations<K> {
|
||||
this.ops = operations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public K getKey() {
|
||||
return key;
|
||||
}
|
||||
@@ -43,22 +44,27 @@ abstract class DefaultBoundKeyOperations<K> implements BoundKeyOperations<K> {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expire(long timeout, TimeUnit unit) {
|
||||
return ops.expire(key, timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expireAt(Date date) {
|
||||
return ops.expireAt(key, date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getExpire() {
|
||||
return ops.getExpire(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean persist() {
|
||||
return ops.persist(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(K newKey) {
|
||||
ops.rename(key, newKey);
|
||||
key = newKey;
|
||||
|
||||
@@ -42,74 +42,92 @@ class DefaultBoundListOperations<K, V> extends DefaultBoundKeyOperations<K> impl
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RedisOperations<K, V> getOperations() {
|
||||
return ops.getOperations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V index(long index) {
|
||||
return ops.index(getKey(), index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V leftPop() {
|
||||
return ops.leftPop(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public V leftPop(long timeout, TimeUnit unit) {
|
||||
return ops.leftPop(getKey(), timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long leftPush(V value) {
|
||||
return ops.leftPush(getKey(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long leftPushIfPresent(V value) {
|
||||
return ops.leftPushIfPresent(getKey(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long leftPush(V pivot, V value) {
|
||||
return ops.leftPush(getKey(), pivot, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size() {
|
||||
return ops.size(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<V> range(long start, long end) {
|
||||
return ops.range(getKey(), start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long remove(long i, Object value) {
|
||||
return ops.remove(getKey(), i, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V rightPop() {
|
||||
return ops.rightPop(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public V rightPop(long timeout, TimeUnit unit) {
|
||||
return ops.rightPop(getKey(), timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rightPushIfPresent(V value) {
|
||||
return ops.rightPushIfPresent(getKey(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rightPush(V value) {
|
||||
return ops.rightPush(getKey(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rightPush(V pivot, V value) {
|
||||
return ops.rightPush(getKey(), pivot, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trim(long start, long end) {
|
||||
ops.trim(getKey(), start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(long index, V value) {
|
||||
ops.set(getKey(), index, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getType() {
|
||||
return DataType.LIST;
|
||||
}
|
||||
|
||||
@@ -42,92 +42,114 @@ class DefaultBoundSetOperations<K, V> extends DefaultBoundKeyOperations<K> imple
|
||||
this.ops = operations.opsForSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean add(V value) {
|
||||
return ops.add(getKey(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<V> diff(K key) {
|
||||
return ops.difference(getKey(), key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<V> diff(Collection<K> keys) {
|
||||
return ops.difference(getKey(), keys);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void diffAndStore(K key, K destKey) {
|
||||
ops.differenceAndStore(getKey(), key, destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void diffAndStore(Collection<K> keys, K destKey) {
|
||||
ops.differenceAndStore(getKey(), keys, destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisOperations<K, V> getOperations() {
|
||||
return ops.getOperations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<V> intersect(K key) {
|
||||
return ops.intersect(getKey(), key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<V> intersect(Collection<K> keys) {
|
||||
return ops.intersect(getKey(), keys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void intersectAndStore(K key, K destKey) {
|
||||
ops.intersectAndStore(getKey(), key, destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void intersectAndStore(Collection<K> keys, K destKey) {
|
||||
ops.intersectAndStore(getKey(), keys, destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isMember(Object o) {
|
||||
return ops.isMember(getKey(), o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<V> members() {
|
||||
return ops.members(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean move(K destKey, V value) {
|
||||
return ops.move(getKey(), value, destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V randomMember() {
|
||||
return ops.randomMember(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean remove(Object o) {
|
||||
return ops.remove(getKey(), o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V pop() {
|
||||
return ops.pop(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size() {
|
||||
return ops.size(getKey());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<V> union(K key) {
|
||||
return ops.union(getKey(), key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<V> union(Collection<K> keys) {
|
||||
return ops.union(getKey(), keys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unionAndStore(K key, K destKey) {
|
||||
ops.unionAndStore(getKey(), key, destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unionAndStore(Collection<K> keys, K destKey) {
|
||||
ops.unionAndStore(getKey(), keys, destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getType() {
|
||||
return DataType.SET;
|
||||
}
|
||||
|
||||
@@ -37,50 +37,62 @@ class DefaultBoundValueOperations<K, V> extends DefaultBoundKeyOperations<K> imp
|
||||
this.ops = operations.opsForValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get() {
|
||||
return ops.get(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public V getAndSet(V value) {
|
||||
return ops.getAndSet(getKey(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long increment(long delta) {
|
||||
return ops.increment(getKey(), delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer append(String value) {
|
||||
return ops.append(getKey(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(long start, long end) {
|
||||
return ops.get(getKey(), start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(V value, long timeout, TimeUnit unit) {
|
||||
ops.set(getKey(), value, timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(V value) {
|
||||
ops.set(getKey(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean setIfAbsent(V value) {
|
||||
return ops.setIfAbsent(getKey(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(V value, long offset) {
|
||||
ops.set(getKey(), value, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size() {
|
||||
return ops.size(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisOperations<K, V> getOperations() {
|
||||
return ops.getOperations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getType() {
|
||||
return DataType.STRING;
|
||||
}
|
||||
|
||||
@@ -41,78 +41,97 @@ class DefaultBoundZSetOperations<K, V> extends DefaultBoundKeyOperations<K> impl
|
||||
this.ops = operations.opsForZSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean add(V value, double score) {
|
||||
return ops.add(getKey(), value, score);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double incrementScore(V value, double delta) {
|
||||
return ops.incrementScore(getKey(), value, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisOperations<K, V> getOperations() {
|
||||
return ops.getOperations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void intersectAndStore(K destKey, K otherKey) {
|
||||
ops.intersectAndStore(getKey(), otherKey, destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void intersectAndStore(Collection<K> otherKeys, K destKey) {
|
||||
ops.intersectAndStore(getKey(), otherKeys, destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<V> range(long start, long end) {
|
||||
return ops.range(getKey(), start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<V> rangeByScore(double min, double max) {
|
||||
return ops.rangeByScore(getKey(), min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rank(Object o) {
|
||||
return ops.rank(getKey(), o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long reverseRank(Object o) {
|
||||
return ops.reverseRank(getKey(), o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double score(Object o) {
|
||||
return ops.score(getKey(), o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean remove(Object o) {
|
||||
return ops.remove(getKey(), o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRange(long start, long end) {
|
||||
ops.removeRange(getKey(), start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRangeByScore(double min, double max) {
|
||||
ops.removeRangeByScore(getKey(), min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<V> reverseRange(long start, long end) {
|
||||
return ops.reverseRange(getKey(), start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long count(double min, double max) {
|
||||
return ops.count(getKey(), min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size() {
|
||||
return ops.size(getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unionAndStore(K otherKey, K destKey) {
|
||||
ops.unionAndStore(getKey(), otherKey, destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unionAndStore(Collection<K> otherKeys, K destKey) {
|
||||
ops.unionAndStore(getKey(), otherKeys, destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getType() {
|
||||
return DataType.ZSET;
|
||||
}
|
||||
|
||||
@@ -37,11 +37,13 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public HV get(K key, Object hashKey) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawHashKey = rawHashKey(hashKey);
|
||||
|
||||
byte[] rawHashValue = execute(new RedisCallback<byte[]>() {
|
||||
@Override
|
||||
public byte[] doInRedis(RedisConnection connection) {
|
||||
return connection.hGet(rawKey, rawHashKey);
|
||||
}
|
||||
@@ -50,22 +52,26 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
return (HV) deserializeHashValue(rawHashValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hasKey(K key, Object hashKey) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawHashKey = rawHashKey(hashKey);
|
||||
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.hExists(rawKey, rawHashKey);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long increment(K key, HK hashKey, final long delta) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawHashKey = rawHashKey(hashKey);
|
||||
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.hIncrBy(rawKey, rawHashKey, delta);
|
||||
}
|
||||
@@ -73,10 +79,12 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<HK> keys(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
Set<byte[]> rawValues = execute(new RedisCallback<Set<byte[]>>() {
|
||||
@Override
|
||||
public Set<byte[]> doInRedis(RedisConnection connection) {
|
||||
return connection.hKeys(rawKey);
|
||||
}
|
||||
@@ -85,16 +93,19 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
return deserializeHashKeys(rawValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.hLen(rawKey);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(K key, Map<? extends HK, ? extends HV> m) {
|
||||
if (m.isEmpty()) {
|
||||
return;
|
||||
@@ -109,6 +120,7 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
}
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.hMSet(rawKey, hashes);
|
||||
return null;
|
||||
@@ -117,6 +129,7 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<HV> multiGet(K key, Collection<HK> fields) {
|
||||
if (fields.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
@@ -132,6 +145,7 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
}
|
||||
|
||||
List<byte[]> rawValues = execute(new RedisCallback<List<byte[]>>() {
|
||||
@Override
|
||||
public List<byte[]> doInRedis(RedisConnection connection) {
|
||||
return connection.hMGet(rawKey, rawHashKeys);
|
||||
}
|
||||
@@ -140,12 +154,14 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
return deserializeHashValues(rawValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(K key, HK hashKey, HV value) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawHashKey = rawHashKey(hashKey);
|
||||
final byte[] rawHashValue = rawHashValue(value);
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.hSet(rawKey, rawHashKey, rawHashValue);
|
||||
return null;
|
||||
@@ -153,12 +169,14 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean putIfAbsent(K key, HK hashKey, HV value) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawHashKey = rawHashKey(hashKey);
|
||||
final byte[] rawHashValue = rawHashValue(value);
|
||||
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.hSetNX(rawKey, rawHashKey, rawHashValue);
|
||||
}
|
||||
@@ -166,10 +184,12 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<HV> values(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
List<byte[]> rawValues = execute(new RedisCallback<List<byte[]>>() {
|
||||
@Override
|
||||
public List<byte[]> doInRedis(RedisConnection connection) {
|
||||
return connection.hVals(rawKey);
|
||||
}
|
||||
@@ -178,11 +198,13 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
return deserializeHashValues(rawValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(K key, Object hashKey) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawHashKey = rawHashKey(hashKey);
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.hDel(rawKey, rawHashKey);
|
||||
return null;
|
||||
@@ -190,10 +212,12 @@ class DefaultHashOperations<K, HK, HV> extends AbstractOperations<K, Object> imp
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<HK, HV> entries(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
Map<byte[], byte[]> entries = execute(new RedisCallback<Map<byte[], byte[]>>() {
|
||||
@Override
|
||||
public Map<byte[], byte[]> doInRedis(RedisConnection connection) {
|
||||
return connection.hGetAll(rawKey);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ class DefaultListOperations<K, V> extends AbstractOperations<K, V> implements Li
|
||||
super(template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V index(K key, final long index) {
|
||||
return execute(new ValueDeserializingRedisCallback(key) {
|
||||
@Override
|
||||
@@ -41,6 +42,7 @@ class DefaultListOperations<K, V> extends AbstractOperations<K, V> implements Li
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V leftPop(K key) {
|
||||
return execute(new ValueDeserializingRedisCallback(key) {
|
||||
@Override
|
||||
@@ -50,6 +52,7 @@ class DefaultListOperations<K, V> extends AbstractOperations<K, V> implements Li
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V leftPop(K key, long timeout, TimeUnit unit) {
|
||||
final int tm = (int) unit.toSeconds(timeout);
|
||||
|
||||
@@ -61,65 +64,79 @@ class DefaultListOperations<K, V> extends AbstractOperations<K, V> implements Li
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long leftPush(K key, V value) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.lPush(rawKey, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long leftPushIfPresent(K key, V value) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.lPushX(rawKey, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long leftPush(K key, V pivot, V value) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawPivot = rawValue(pivot);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.lInsert(rawKey, Position.BEFORE, rawPivot, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.lLen(rawKey);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<V> range(K key, final long start, final long end) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
return execute(new RedisCallback<List<V>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<V> doInRedis(RedisConnection connection) {
|
||||
return deserializeValues(connection.lRange(rawKey, start, end));
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long remove(K key, final long count, Object value) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.lRem(rawKey, count, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V rightPop(K key) {
|
||||
return execute(new ValueDeserializingRedisCallback(key) {
|
||||
@Override
|
||||
@@ -129,6 +146,7 @@ class DefaultListOperations<K, V> extends AbstractOperations<K, V> implements Li
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V rightPop(K key, long timeout, TimeUnit unit) {
|
||||
final int tm = (int) unit.toSeconds(timeout);
|
||||
|
||||
@@ -140,38 +158,45 @@ class DefaultListOperations<K, V> extends AbstractOperations<K, V> implements Li
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rightPush(K key, V value) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.rPush(rawKey, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rightPushIfPresent(K key, V value) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.rPushX(rawKey, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rightPush(K key, V pivot, V value) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawPivot = rawValue(pivot);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.lInsert(rawKey, Position.AFTER, rawPivot, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V rightPopAndLeftPush(K sourceKey, K destinationKey) {
|
||||
final byte[] rawDestKey = rawKey(destinationKey);
|
||||
|
||||
@@ -183,6 +208,7 @@ class DefaultListOperations<K, V> extends AbstractOperations<K, V> implements Li
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V rightPopAndLeftPush(K sourceKey, K destinationKey, long timeout, TimeUnit unit) {
|
||||
final int tm = (int) unit.toSeconds(timeout);
|
||||
final byte[] rawDestKey = rawKey(destinationKey);
|
||||
@@ -195,6 +221,7 @@ class DefaultListOperations<K, V> extends AbstractOperations<K, V> implements Li
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(K key, final long index, V value) {
|
||||
final byte[] rawValue = rawValue(value);
|
||||
execute(new ValueDeserializingRedisCallback(key) {
|
||||
@@ -206,6 +233,7 @@ class DefaultListOperations<K, V> extends AbstractOperations<K, V> implements Li
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trim(K key, final long start, final long end) {
|
||||
execute(new ValueDeserializingRedisCallback(key) {
|
||||
@Override
|
||||
|
||||
@@ -32,23 +32,29 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
|
||||
super(template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean add(K key, V value) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.sAdd(rawKey, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<V> difference(K key, K otherKey) {
|
||||
return difference(key, Collections.singleton(otherKey));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Set<V> difference(final K key, final Collection<K> otherKeys) {
|
||||
final byte[][] rawKeys = rawKeys(key, otherKeys);
|
||||
Set<byte[]> rawValues = execute(new RedisCallback<Set<byte[]>>() {
|
||||
@Override
|
||||
public Set<byte[]> doInRedis(RedisConnection connection) {
|
||||
return connection.sDiff(rawKeys);
|
||||
}
|
||||
@@ -57,14 +63,17 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
|
||||
return deserializeValues(rawValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void differenceAndStore(K key, K otherKey, K destKey) {
|
||||
differenceAndStore(key, Collections.singleton(otherKey), destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void differenceAndStore(final K key, final Collection<K> otherKeys, K destKey) {
|
||||
final byte[][] rawKeys = rawKeys(key, otherKeys);
|
||||
final byte[] rawDestKey = rawKey(destKey);
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.sDiffStore(rawDestKey, rawKeys);
|
||||
return null;
|
||||
@@ -72,13 +81,17 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<V> intersect(K key, K otherKey) {
|
||||
return intersect(key, Collections.singleton(otherKey));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Set<V> intersect(K key, Collection<K> otherKeys) {
|
||||
final byte[][] rawKeys = rawKeys(key, otherKeys);
|
||||
Set<byte[]> rawValues = execute(new RedisCallback<Set<byte[]>>() {
|
||||
@Override
|
||||
public Set<byte[]> doInRedis(RedisConnection connection) {
|
||||
return connection.sInter(rawKeys);
|
||||
}
|
||||
@@ -87,14 +100,17 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
|
||||
return deserializeValues(rawValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void intersectAndStore(K key, K otherKey, K destKey) {
|
||||
intersectAndStore(key, Collections.singleton(otherKey), destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void intersectAndStore(K key, Collection<K> otherKeys, K destKey) {
|
||||
final byte[][] rawKeys = rawKeys(key, otherKeys);
|
||||
final byte[] rawDestKey = rawKey(destKey);
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.sInterStore(rawDestKey, rawKeys);
|
||||
return null;
|
||||
@@ -102,19 +118,24 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isMember(K key, Object o) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(o);
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.sIsMember(rawKey, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Set<V> members(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
Set<byte[]> rawValues = execute(new RedisCallback<Set<byte[]>>() {
|
||||
@Override
|
||||
public Set<byte[]> doInRedis(RedisConnection connection) {
|
||||
return connection.sMembers(rawKey);
|
||||
}
|
||||
@@ -123,18 +144,21 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
|
||||
return deserializeValues(rawValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean move(K key, V value, K destKey) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawDestKey = rawKey(destKey);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.sMove(rawKey, rawDestKey, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V randomMember(K key) {
|
||||
|
||||
return execute(new ValueDeserializingRedisCallback(key) {
|
||||
@@ -145,16 +169,19 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean remove(K key, Object o) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(o);
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.sRem(rawKey, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V pop(K key) {
|
||||
return execute(new ValueDeserializingRedisCallback(key) {
|
||||
@Override
|
||||
@@ -164,22 +191,28 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.sCard(rawKey);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<V> union(K key, K otherKey) {
|
||||
return union(key, Collections.singleton(otherKey));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Set<V> union(K key, Collection<K> otherKeys) {
|
||||
final byte[][] rawKeys = rawKeys(key, otherKeys);
|
||||
Set<byte[]> rawValues = execute(new RedisCallback<Set<byte[]>>() {
|
||||
@Override
|
||||
public Set<byte[]> doInRedis(RedisConnection connection) {
|
||||
return connection.sUnion(rawKeys);
|
||||
}
|
||||
@@ -188,14 +221,17 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
|
||||
return deserializeValues(rawValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unionAndStore(K key, K otherKey, K destKey) {
|
||||
unionAndStore(key, Collections.singleton(otherKey), destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unionAndStore(K key, Collection<K> otherKeys, K destKey) {
|
||||
final byte[][] rawKeys = rawKeys(key, otherKeys);
|
||||
final byte[] rawDestKey = rawKey(destKey);
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.sUnionStore(rawDestKey, rawKeys);
|
||||
return null;
|
||||
|
||||
@@ -36,6 +36,7 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
super(template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(final Object key) {
|
||||
|
||||
return execute(new ValueDeserializingRedisCallback(key) {
|
||||
@@ -46,6 +47,7 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V getAndSet(K key, V newValue) {
|
||||
final byte[] rawValue = rawValue(newValue);
|
||||
return execute(new ValueDeserializingRedisCallback(key) {
|
||||
@@ -56,10 +58,12 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long increment(K key, final long delta) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
// TODO add conversion service in here ?
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
if (delta == 1) {
|
||||
return connection.incr(rawKey);
|
||||
@@ -78,21 +82,25 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer append(K key, String value) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawString = rawString(value);
|
||||
|
||||
return execute(new RedisCallback<Integer>() {
|
||||
@Override
|
||||
public Integer doInRedis(RedisConnection connection) {
|
||||
return connection.append(rawKey, rawString).intValue();
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(K key, final long start, final long end) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
byte[] rawReturn = execute(new RedisCallback<byte[]>() {
|
||||
@Override
|
||||
public byte[] doInRedis(RedisConnection connection) {
|
||||
return connection.getRange(rawKey, start, end);
|
||||
}
|
||||
@@ -101,6 +109,8 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
return deserializeString(rawReturn);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<V> multiGet(Collection<K> keys) {
|
||||
if (keys.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
@@ -114,6 +124,7 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
}
|
||||
|
||||
List<byte[]> rawValues = execute(new RedisCallback<List<byte[]>>() {
|
||||
@Override
|
||||
public List<byte[]> doInRedis(RedisConnection connection) {
|
||||
return connection.mGet(rawKeys);
|
||||
}
|
||||
@@ -122,6 +133,7 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
return deserializeValues(rawValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void multiSet(Map<? extends K, ? extends V> m) {
|
||||
if (m.isEmpty()) {
|
||||
return;
|
||||
@@ -134,6 +146,7 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
}
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.mSet(rawKeys);
|
||||
return null;
|
||||
@@ -141,6 +154,7 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void multiSetIfAbsent(Map<? extends K, ? extends V> m) {
|
||||
if (m.isEmpty()) {
|
||||
return;
|
||||
@@ -153,6 +167,7 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
}
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.mSetNX(rawKeys);
|
||||
return null;
|
||||
@@ -160,6 +175,7 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(K key, V value) {
|
||||
final byte[] rawValue = rawValue(value);
|
||||
execute(new ValueDeserializingRedisCallback(key) {
|
||||
@@ -171,12 +187,14 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(K key, V value, long timeout, TimeUnit unit) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
final long rawTimeout = unit.toSeconds(timeout);
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
connection.setEx(rawKey, (int) rawTimeout, rawValue);
|
||||
return null;
|
||||
@@ -184,11 +202,13 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean setIfAbsent(K key, V value) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
return connection.setNX(rawKey, rawValue);
|
||||
}
|
||||
@@ -196,11 +216,13 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void set(K key, final V value, final long offset) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.setRange(rawKey, rawValue, offset);
|
||||
return null;
|
||||
@@ -208,10 +230,12 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.strLen(rawKey);
|
||||
}
|
||||
|
||||
@@ -32,36 +32,43 @@ class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZS
|
||||
super(template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean add(final K key, final V value, final double score) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.zAdd(rawKey, score, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double incrementScore(K key, V value, final double delta) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(value);
|
||||
|
||||
return execute(new RedisCallback<Double>() {
|
||||
@Override
|
||||
public Double doInRedis(RedisConnection connection) {
|
||||
return connection.zIncrBy(rawKey, delta, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void intersectAndStore(K key, K otherKey, K destKey) {
|
||||
intersectAndStore(key, Collections.singleton(otherKey), destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void intersectAndStore(K key, Collection<K> otherKeys, K destKey) {
|
||||
final byte[][] rawKeys = rawKeys(key, otherKeys);
|
||||
final byte[] rawDestKey = rawKey(destKey);
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.zInterStore(rawDestKey, rawKeys);
|
||||
return null;
|
||||
@@ -69,10 +76,13 @@ class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZS
|
||||
}, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Set<V> range(K key, final long start, final long end) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
Set<byte[]> rawValues = execute(new RedisCallback<Set<byte[]>>() {
|
||||
@Override
|
||||
public Set<byte[]> doInRedis(RedisConnection connection) {
|
||||
return connection.zRange(rawKey, start, end);
|
||||
}
|
||||
@@ -81,10 +91,13 @@ class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZS
|
||||
return deserializeValues(rawValues);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Set<V> rangeByScore(K key, final double min, final double max) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
Set<byte[]> rawValues = execute(new RedisCallback<Set<byte[]>>() {
|
||||
@Override
|
||||
public Set<byte[]> doInRedis(RedisConnection connection) {
|
||||
return connection.zRangeByScore(rawKey, min, max);
|
||||
}
|
||||
@@ -93,11 +106,13 @@ class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZS
|
||||
return deserializeValues(rawValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rank(K key, Object o) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(o);
|
||||
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
Long zRank = connection.zRank(rawKey, rawValue);
|
||||
return (zRank != null && zRank.longValue() >= 0 ? zRank : null);
|
||||
@@ -105,11 +120,13 @@ class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZS
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long reverseRank(K key, Object o) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(o);
|
||||
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
Long zRank = connection.zRevRank(rawKey, rawValue);
|
||||
return (zRank != null && zRank.longValue() >= 0 ? zRank : null);
|
||||
@@ -117,20 +134,24 @@ class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZS
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean remove(K key, Object o) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(o);
|
||||
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.zRem(rawKey, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRange(K key, final long start, final long end) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.zRemRange(rawKey, start, end);
|
||||
return null;
|
||||
@@ -138,9 +159,11 @@ class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZS
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRangeByScore(K key, final double min, final double max) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.zRemRangeByScore(rawKey, min, max);
|
||||
return null;
|
||||
@@ -148,10 +171,13 @@ class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZS
|
||||
}, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Set<V> reverseRange(K key, final long start, final long end) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
Set<byte[]> rawValues = execute(new RedisCallback<Set<byte[]>>() {
|
||||
@Override
|
||||
public Set<byte[]> doInRedis(RedisConnection connection) {
|
||||
return connection.zRevRange(rawKey, start, end);
|
||||
}
|
||||
@@ -160,45 +186,54 @@ class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZS
|
||||
return deserializeValues(rawValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double score(K key, Object o) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(o);
|
||||
|
||||
return execute(new RedisCallback<Double>() {
|
||||
@Override
|
||||
public Double doInRedis(RedisConnection connection) {
|
||||
return connection.zScore(rawKey, rawValue);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long count(K key, final double min, final double max) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.zCount(rawKey, min, max);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.zCard(rawKey);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unionAndStore(K key, K otherKey, K destKey) {
|
||||
unionAndStore(key, Collections.singleton(otherKey), destKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unionAndStore(K key, Collection<K> otherKeys, K destKey) {
|
||||
final byte[][] rawKeys = rawKeys(key, otherKeys);
|
||||
final byte[] rawDestKey = rawKey(destKey);
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.zUnionStore(rawDestKey, rawKeys);
|
||||
return null;
|
||||
|
||||
@@ -173,6 +173,7 @@ public abstract class RedisConnectionUtils {
|
||||
this.conn = conn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoid() {
|
||||
return isVoid;
|
||||
}
|
||||
@@ -181,10 +182,12 @@ public abstract class RedisConnectionUtils {
|
||||
return conn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unbound() {
|
||||
this.isVoid = true;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
zSetOps = new DefaultZSetOperations<K, V>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T execute(RedisCallback<T> action) {
|
||||
return execute(action, isExposeConnection());
|
||||
}
|
||||
@@ -191,6 +192,7 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T> T execute(SessionCallback<T> session) {
|
||||
RedisConnectionFactory factory = getConnectionFactory();
|
||||
// bind connection
|
||||
@@ -423,19 +425,23 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
//
|
||||
// RedisOperations
|
||||
//
|
||||
@Override
|
||||
public List<Object> exec() {
|
||||
return execute(new RedisCallback<List<Object>>() {
|
||||
|
||||
@Override
|
||||
public List<Object> doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
return connection.exec();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.del(rawKey);
|
||||
return null;
|
||||
@@ -443,10 +449,12 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Collection<K> keys) {
|
||||
final byte[][] rawKeys = rawKeys(keys);
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.del(rawKeys);
|
||||
return null;
|
||||
@@ -454,38 +462,45 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hasKey(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.exists(rawKey);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expire(K key, long timeout, TimeUnit unit) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final int rawTimeout = (int) unit.toSeconds(timeout);
|
||||
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.expire(rawKey, rawTimeout);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expireAt(K key, Date date) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final long rawTimeout = date.getTime();
|
||||
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.expireAt(rawKey, rawTimeout);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convertAndSend(String channel, Object message) {
|
||||
Assert.hasText(channel, "a non-empty channel is required");
|
||||
|
||||
@@ -493,6 +508,7 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
final byte[] rawMessage = rawValue(message);
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.publish(rawChannel, rawMessage);
|
||||
return null;
|
||||
@@ -505,10 +521,12 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
// Value operations
|
||||
//
|
||||
|
||||
@Override
|
||||
public Long getExpire(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return Long.valueOf(connection.ttl(rawKey));
|
||||
}
|
||||
@@ -516,10 +534,12 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Set<K> keys(K pattern) {
|
||||
final byte[] rawKey = rawKey(pattern);
|
||||
|
||||
Collection<byte[]> rawKeys = execute(new RedisCallback<Collection<byte[]>>() {
|
||||
@Override
|
||||
public Collection<byte[]> doInRedis(RedisConnection connection) {
|
||||
return connection.keys(rawKey);
|
||||
}
|
||||
@@ -528,28 +548,34 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
return (Set<K>) SerializationUtils.deserialize(rawKeys, keySerializer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean persist(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.persist(rawKey);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean move(K key, final int dbIndex) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.move(rawKey, dbIndex);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public K randomKey() {
|
||||
byte[] rawKey = execute(new RedisCallback<byte[]>() {
|
||||
@Override
|
||||
public byte[] doInRedis(RedisConnection connection) {
|
||||
return connection.randomKey();
|
||||
}
|
||||
@@ -558,11 +584,13 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
return deserializeKey(rawKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(K oldKey, K newKey) {
|
||||
final byte[] rawOldKey = rawKey(oldKey);
|
||||
final byte[] rawNewKey = rawKey(newKey);
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.rename(rawOldKey, rawNewKey);
|
||||
return null;
|
||||
@@ -570,29 +598,35 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean renameIfAbsent(K oldKey, K newKey) {
|
||||
final byte[] rawOldKey = rawKey(oldKey);
|
||||
final byte[] rawNewKey = rawKey(newKey);
|
||||
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.renameNX(rawOldKey, rawNewKey);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType type(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
return execute(new RedisCallback<DataType>() {
|
||||
@Override
|
||||
public DataType doInRedis(RedisConnection connection) {
|
||||
return connection.type(rawKey);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void multi() {
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
connection.multi();
|
||||
return null;
|
||||
@@ -600,9 +634,11 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
execute(new RedisCallback<Object>() {
|
||||
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
connection.discard();
|
||||
return null;
|
||||
@@ -610,10 +646,12 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.watch(rawKey);
|
||||
return null;
|
||||
@@ -621,10 +659,12 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(Collection<K> keys) {
|
||||
final byte[][] rawKeys = rawKeys(keys);
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.watch(rawKeys);
|
||||
return null;
|
||||
@@ -632,8 +672,10 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unwatch() {
|
||||
execute(new RedisCallback<Object>() {
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
connection.unwatch();
|
||||
return null;
|
||||
@@ -644,15 +686,18 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
// Sort operations
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<V> sort(SortQuery<K> query) {
|
||||
return sort(query, valueSerializer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> sort(SortQuery<K> query, RedisSerializer<T> resultSerializer) {
|
||||
final byte[] rawKey = rawKey(query.getKey());
|
||||
final SortParameters params = QueryUtils.convertQuery(query, stringSerializer);
|
||||
|
||||
List<byte[]> vals = execute(new RedisCallback<List<byte[]>>() {
|
||||
@Override
|
||||
public List<byte[]> doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
return connection.sort(rawKey, params);
|
||||
}
|
||||
@@ -662,10 +707,12 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> List<T> sort(SortQuery<K> query, BulkMapper<T, V> bulkMapper) {
|
||||
return sort(query, bulkMapper, valueSerializer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T, S> List<T> sort(SortQuery<K> query, BulkMapper<T, S> bulkMapper, RedisSerializer<S> resultSerializer) {
|
||||
List<S> values = sort(query, resultSerializer);
|
||||
|
||||
@@ -686,54 +733,66 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long sort(SortQuery<K> query, K storeKey) {
|
||||
final byte[] rawStoreKey = rawKey(storeKey);
|
||||
final byte[] rawKey = rawKey(query.getKey());
|
||||
final SortParameters params = QueryUtils.convertQuery(query, stringSerializer);
|
||||
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
return connection.sort(rawKey, params, rawStoreKey);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundValueOperations<K, V> boundValueOps(K key) {
|
||||
return new DefaultBoundValueOperations<K, V>(key, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueOperations<K, V> opsForValue() {
|
||||
return valueOps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListOperations<K, V> opsForList() {
|
||||
return listOps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundListOperations<K, V> boundListOps(K key) {
|
||||
return new DefaultBoundListOperations<K, V>(key, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundSetOperations<K, V> boundSetOps(K key) {
|
||||
return new DefaultBoundSetOperations<K, V>(key, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetOperations<K, V> opsForSet() {
|
||||
return setOps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoundZSetOperations<K, V> boundZSetOps(K key) {
|
||||
return new DefaultBoundZSetOperations<K, V>(key, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZSetOperations<K, V> opsForZSet() {
|
||||
return zSetOps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <HK, HV> BoundHashOperations<K, HK, HV> boundHashOps(K key) {
|
||||
return new DefaultBoundHashOperations<K, HK, HV>(key, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <HK, HV> HashOperations<K, HK, HV> opsForHash() {
|
||||
return new DefaultHashOperations<K, HK, HV>(this);
|
||||
}
|
||||
|
||||
@@ -40,30 +40,36 @@ class DefaultSortCriterion<K> implements SortCriterion<K> {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortCriterion<K> alphabetical(boolean alpha) {
|
||||
this.alpha = Boolean.valueOf(alpha);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortQuery<K> build() {
|
||||
return new DefaultSortQuery<K>(key, by, limit, order, alpha, getKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortCriterion<K> limit(long offset, long count) {
|
||||
this.limit = new Range(offset, count);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortCriterion<K> limit(Range range) {
|
||||
this.limit = range;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortCriterion<K> order(Order order) {
|
||||
this.order = order;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortCriterion<K> get(String getPattern) {
|
||||
this.getKeys.add(getPattern);
|
||||
return this;
|
||||
|
||||
@@ -43,26 +43,32 @@ class DefaultSortQuery<K> implements SortQuery<K> {
|
||||
this.gets = gets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBy() {
|
||||
return by;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Range getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isAlphabetic() {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public K getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGetPattern() {
|
||||
return gets;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public class BeanUtilsHashMapper<T> implements HashMapper<T, String, String> {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromHash(Map<String, String> hash) {
|
||||
T instance = org.springframework.beans.BeanUtils.instantiate(type);
|
||||
try {
|
||||
@@ -42,6 +43,7 @@ public class BeanUtilsHashMapper<T> implements HashMapper<T, String, String> {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> toHash(T object) {
|
||||
try {
|
||||
return BeanUtils.describe(object);
|
||||
|
||||
@@ -33,11 +33,13 @@ public class DecoratingStringHashMapper<T> implements HashMapper<T, String, Stri
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public T fromHash(Map<String, String> hash) {
|
||||
Map h = hash;
|
||||
return delegate.fromHash(h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> toHash(T object) {
|
||||
Map<?, ?> hash = delegate.toHash(object);
|
||||
Map<String, String> flatten = new LinkedHashMap<String, String>(hash.size());
|
||||
|
||||
@@ -42,10 +42,12 @@ public class JacksonHashMapper<T> implements HashMapper<T, String, Object> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public T fromHash(Map<String, Object> hash) {
|
||||
return (T) mapper.convertValue(hash, userType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toHash(T object) {
|
||||
return mapper.convertValue(object, mapType);
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ public class RedisMessageListenerContainer implements InitializingBean, Disposab
|
||||
private volatile RedisSerializer<String> serializer = new StringRedisSerializer();
|
||||
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
if (taskExecutor == null) {
|
||||
manageExecutor = true;
|
||||
@@ -136,6 +137,7 @@ public class RedisMessageListenerContainer implements InitializingBean, Disposab
|
||||
return new SimpleAsyncTaskExecutor(threadNamePrefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
initialized = false;
|
||||
|
||||
@@ -152,24 +154,29 @@ public class RedisMessageListenerContainer implements InitializingBean, Disposab
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoStartup() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(Runnable callback) {
|
||||
stop();
|
||||
callback.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPhase() {
|
||||
// start the latest
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (!running) {
|
||||
running = true;
|
||||
@@ -191,6 +198,7 @@ public class RedisMessageListenerContainer implements InitializingBean, Disposab
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (isRunning()) {
|
||||
running = false;
|
||||
@@ -293,6 +301,7 @@ public class RedisMessageListenerContainer implements InitializingBean, Disposab
|
||||
this.connectionFactory = connectionFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
this.beanName = name;
|
||||
}
|
||||
@@ -501,10 +510,12 @@ public class RedisMessageListenerContainer implements InitializingBean, Disposab
|
||||
private long WAIT = 500;
|
||||
private long ROUNDS = 3;
|
||||
|
||||
@Override
|
||||
public boolean isLongLived() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// wait for subscription to be initialized
|
||||
boolean done = false;
|
||||
@@ -532,10 +543,12 @@ public class RedisMessageListenerContainer implements InitializingBean, Disposab
|
||||
private volatile RedisConnection connection;
|
||||
private final Object localMonitor = new Object();
|
||||
|
||||
@Override
|
||||
public boolean isLongLived() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
connection = connectionFactory.getConnection();
|
||||
try {
|
||||
@@ -682,6 +695,7 @@ public class RedisMessageListenerContainer implements InitializingBean, Disposab
|
||||
*/
|
||||
private class DispatchMessageListener implements MessageListener {
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
// do channel matching first
|
||||
byte[] channel = message.getChannel();
|
||||
@@ -706,6 +720,7 @@ public class RedisMessageListenerContainer implements InitializingBean, Disposab
|
||||
private void dispatchChannels(Collection<MessageListener> ch, final Message message) {
|
||||
for (final MessageListener messageListener : ch) {
|
||||
taskExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
processMessage(messageListener, message, null);
|
||||
}
|
||||
@@ -716,6 +731,7 @@ public class RedisMessageListenerContainer implements InitializingBean, Disposab
|
||||
private void dispatchPatterns(Collection<MessageListener> pt, final Message message, final byte[] pattern) {
|
||||
for (final MessageListener messageListener : pt) {
|
||||
taskExecutor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
processMessage(messageListener, message, pattern.clone());
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.keyvalue.redis.connection.Message;
|
||||
import org.springframework.data.keyvalue.redis.connection.MessageListener;
|
||||
import org.springframework.data.keyvalue.redis.serializer.JdkSerializationRedisSerializer;
|
||||
import org.springframework.data.keyvalue.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.keyvalue.redis.serializer.StringRedisSerializer;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -165,6 +166,8 @@ public class MessageListenerAdapter implements MessageListener {
|
||||
* @param message the incoming Redis message
|
||||
* @see #handleListenerException
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
try {
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ public class GenericToStringSerializer<T> implements RedisSerializer<T>, BeanFac
|
||||
converter = new Converter(typeConverter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T deserialize(byte[] bytes) {
|
||||
if (bytes == null) {
|
||||
return null;
|
||||
@@ -73,6 +74,7 @@ public class GenericToStringSerializer<T> implements RedisSerializer<T>, BeanFac
|
||||
return converter.convert(string, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] serialize(T object) {
|
||||
if (object == null) {
|
||||
return null;
|
||||
@@ -81,6 +83,7 @@ public class GenericToStringSerializer<T> implements RedisSerializer<T>, BeanFac
|
||||
return string.getBytes(charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
if (converter == null && beanFactory instanceof ConfigurableBeanFactory) {
|
||||
ConfigurableBeanFactory cFB = (ConfigurableBeanFactory) beanFactory;
|
||||
|
||||
@@ -44,6 +44,7 @@ public class JacksonJsonRedisSerializer<T> implements RedisSerializer<T> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public T deserialize(byte[] bytes) throws SerializationException {
|
||||
if (SerializationUtils.isEmpty(bytes)) {
|
||||
return null;
|
||||
@@ -55,6 +56,7 @@ public class JacksonJsonRedisSerializer<T> implements RedisSerializer<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] serialize(Object t) throws SerializationException {
|
||||
if (t == null) {
|
||||
return SerializationUtils.EMPTY_ARRAY;
|
||||
|
||||
@@ -32,6 +32,7 @@ public class JdkSerializationRedisSerializer implements RedisSerializer<Object>
|
||||
private Converter<byte[], Object> deserializer = new DeserializingConverter();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object deserialize(byte[] bytes) {
|
||||
if (SerializationUtils.isEmpty(bytes)) {
|
||||
return null;
|
||||
@@ -44,6 +45,7 @@ public class JdkSerializationRedisSerializer implements RedisSerializer<Object>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] serialize(Object object) {
|
||||
if (object == null) {
|
||||
return SerializationUtils.EMPTY_ARRAY;
|
||||
|
||||
@@ -50,6 +50,7 @@ public class OxmSerializer implements InitializingBean, RedisSerializer<Object>
|
||||
afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(marshaller, "non-null marshaller required");
|
||||
Assert.notNull(unmarshaller, "non-null unmarshaller required");
|
||||
@@ -69,6 +70,7 @@ public class OxmSerializer implements InitializingBean, RedisSerializer<Object>
|
||||
this.unmarshaller = unmarshaller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deserialize(byte[] bytes) throws SerializationException {
|
||||
if (SerializationUtils.isEmpty(bytes)) {
|
||||
return null;
|
||||
@@ -81,6 +83,7 @@ public class OxmSerializer implements InitializingBean, RedisSerializer<Object>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] serialize(Object t) throws SerializationException {
|
||||
if (t == null) {
|
||||
return SerializationUtils.EMPTY_ARRAY;
|
||||
|
||||
@@ -42,10 +42,12 @@ public class StringRedisSerializer implements RedisSerializer<String> {
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String deserialize(byte[] bytes) {
|
||||
return (bytes == null ? null : new String(bytes, charset));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] serialize(String string) {
|
||||
return (string == null ? null : string.getBytes(charset));
|
||||
}
|
||||
|
||||
@@ -162,6 +162,7 @@ public class RedisAtomicInteger extends Number implements Serializable, BoundKey
|
||||
return generalOps.execute(new SessionCallback<Boolean>() {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Boolean execute(RedisOperations operations) {
|
||||
for (;;) {
|
||||
operations.watch(Collections.singleton(key));
|
||||
@@ -238,57 +239,59 @@ public class RedisAtomicInteger extends Number implements Serializable, BoundKey
|
||||
* Returns the String representation of the current value.
|
||||
* @return the String representation of the current value.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return Integer.toString(get());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int intValue() {
|
||||
return get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long longValue() {
|
||||
return get();
|
||||
return (long) get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float floatValue() {
|
||||
return get();
|
||||
return (float) get();
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return (double) get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double doubleValue() {
|
||||
return get();
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expire(long timeout, TimeUnit unit) {
|
||||
return generalOps.expire(key, timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expireAt(Date date) {
|
||||
return generalOps.expireAt(key, date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getExpire() {
|
||||
return generalOps.getExpire(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean persist() {
|
||||
return generalOps.persist(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(String newKey) {
|
||||
generalOps.rename(key, newKey);
|
||||
key = newKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getType() {
|
||||
return DataType.STRING;
|
||||
}
|
||||
|
||||
@@ -162,6 +162,7 @@ public class RedisAtomicLong extends Number implements Serializable, BoundKeyOpe
|
||||
return generalOps.execute(new SessionCallback<Boolean>() {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Boolean execute(RedisOperations operations) {
|
||||
for (;;) {
|
||||
operations.watch(Collections.singleton(key));
|
||||
@@ -241,57 +242,59 @@ public class RedisAtomicLong extends Number implements Serializable, BoundKeyOpe
|
||||
*
|
||||
* @return the String representation of the current value.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return Long.toString(get());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int intValue() {
|
||||
return (int) get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long longValue() {
|
||||
return get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float floatValue() {
|
||||
return get();
|
||||
return (float) get();
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return (double) get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double doubleValue() {
|
||||
return get();
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expire(long timeout, TimeUnit unit) {
|
||||
return generalOps.expire(key, timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expireAt(Date date) {
|
||||
return generalOps.expireAt(key, date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getExpire() {
|
||||
return generalOps.getExpire(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean persist() {
|
||||
return generalOps.persist(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(String newKey) {
|
||||
generalOps.rename(key, newKey);
|
||||
key = newKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getType() {
|
||||
return DataType.STRING;
|
||||
}
|
||||
|
||||
@@ -40,10 +40,12 @@ public abstract class AbstractRedisCollection<E> extends AbstractCollection<E> i
|
||||
this.operations = operations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisOperations<String, E> getOperations() {
|
||||
return operations;
|
||||
}
|
||||
@@ -57,10 +59,8 @@ public abstract class AbstractRedisCollection<E> extends AbstractCollection<E> i
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean add(E e);
|
||||
|
||||
@Override
|
||||
public abstract void clear();
|
||||
|
||||
@Override
|
||||
@@ -72,7 +72,6 @@ public abstract class AbstractRedisCollection<E> extends AbstractCollection<E> i
|
||||
return contains;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean remove(Object o);
|
||||
|
||||
|
||||
@@ -85,7 +84,6 @@ public abstract class AbstractRedisCollection<E> extends AbstractCollection<E> i
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -121,22 +119,27 @@ public abstract class AbstractRedisCollection<E> extends AbstractCollection<E> i
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expire(long timeout, TimeUnit unit) {
|
||||
return operations.expire(key, timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expireAt(Date date) {
|
||||
return operations.expireAt(key, date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getExpire() {
|
||||
return operations.getExpire(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean persist() {
|
||||
return operations.persist(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(final String newKey) {
|
||||
CollectionUtils.rename(key, newKey, operations);
|
||||
key = newKey;
|
||||
|
||||
@@ -56,6 +56,7 @@ abstract class CollectionUtils {
|
||||
static <K> void rename(final K key, final K newKey, RedisOperations<K, ?> operations) {
|
||||
operations.execute(new SessionCallback<Object>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object execute(RedisOperations operations) throws DataAccessException {
|
||||
do {
|
||||
operations.watch(key);
|
||||
@@ -75,6 +76,7 @@ abstract class CollectionUtils {
|
||||
|
||||
static <K> Boolean renameIfAbsent(final K key, final K newKey, RedisOperations<K, ?> operations) {
|
||||
return operations.execute(new SessionCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean execute(RedisOperations operations) throws DataAccessException {
|
||||
List<Object> exec = null;
|
||||
do {
|
||||
|
||||
@@ -47,6 +47,8 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
|
||||
private volatile boolean capped = false;
|
||||
|
||||
private volatile long defaultWait = 0;
|
||||
|
||||
private class DefaultRedisListIterator extends RedisIterator<E> {
|
||||
|
||||
public DefaultRedisListIterator(Iterator<E> delegate) {
|
||||
@@ -100,10 +102,12 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
capped = (maxSize > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> range(long start, long end) {
|
||||
return listOps.range(start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisList<E> trim(int start, int end) {
|
||||
listOps.trim(start, end);
|
||||
return this;
|
||||
@@ -149,6 +153,7 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
return (result != null && result.longValue() > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, E element) {
|
||||
if (index == 0) {
|
||||
listOps.leftPush(element);
|
||||
@@ -171,6 +176,7 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
throw new IllegalArgumentException("Redis supports insertion only at the beginning or the end of the list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends E> c) {
|
||||
// insert collection in reverse
|
||||
if (index == 0) {
|
||||
@@ -200,6 +206,7 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
throw new IllegalArgumentException("Redis supports insertion only at the beginning or the end of the list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
if (index < 0 || index > size()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
@@ -207,33 +214,40 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
return listOps.index(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator(int index) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public E set(int index, E e) {
|
||||
E object = get(index);
|
||||
listOps.set(index, e);
|
||||
return object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> subList(int fromIndex, int toIndex) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -242,6 +256,7 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
// Queue methods
|
||||
//
|
||||
|
||||
@Override
|
||||
public E element() {
|
||||
E value = peek();
|
||||
if (value == null)
|
||||
@@ -251,6 +266,7 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean offer(E e) {
|
||||
listOps.rightPush(e);
|
||||
cap();
|
||||
@@ -258,16 +274,19 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public E peek() {
|
||||
return listOps.index(0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public E poll() {
|
||||
return listOps.leftPop();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public E remove() {
|
||||
E value = poll();
|
||||
if (value == null)
|
||||
@@ -280,25 +299,30 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
// Dequeue
|
||||
//
|
||||
|
||||
@Override
|
||||
public void addFirst(E e) {
|
||||
listOps.leftPush(e);
|
||||
cap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLast(E e) {
|
||||
add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<E> descendingIterator() {
|
||||
List<E> content = content();
|
||||
Collections.reverse(content);
|
||||
return new DefaultRedisListIterator(content.iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public E getFirst() {
|
||||
return element();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E getLast() {
|
||||
E e = peekLast();
|
||||
if (e == null) {
|
||||
@@ -307,32 +331,39 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
return e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean offerFirst(E e) {
|
||||
addFirst(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean offerLast(E e) {
|
||||
addLast(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E peekFirst() {
|
||||
return peek();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E peekLast() {
|
||||
return listOps.index(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E pollFirst() {
|
||||
return poll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E pollLast() {
|
||||
return listOps.rightPop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E pop() {
|
||||
E e = poll();
|
||||
if (e == null) {
|
||||
@@ -341,18 +372,22 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
return e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void push(E e) {
|
||||
addFirst(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E removeFirst() {
|
||||
return pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeFirstOccurrence(Object o) {
|
||||
return remove(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E removeLast() {
|
||||
E e = pollLast();
|
||||
if (e == null) {
|
||||
@@ -361,6 +396,7 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
return e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeLastOccurrence(Object o) {
|
||||
Long result = listOps.remove(-1, o);
|
||||
return (result != null && result.longValue() > 0);
|
||||
@@ -371,6 +407,7 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
// BlockingQueue
|
||||
//
|
||||
|
||||
@Override
|
||||
public int drainTo(Collection<? super E> c, int maxElements) {
|
||||
if (this.equals(c)) {
|
||||
throw new IllegalArgumentException("Cannot drain a queue to itself");
|
||||
@@ -386,27 +423,33 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
return loop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int drainTo(Collection<? super E> c) {
|
||||
return drainTo(c, size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
|
||||
return offer(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
|
||||
E element = listOps.leftPop(timeout, unit);
|
||||
return (element == null ? null : element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(E e) throws InterruptedException {
|
||||
offer(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remainingCapacity() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E take() throws InterruptedException {
|
||||
return poll(0, TimeUnit.SECONDS);
|
||||
}
|
||||
@@ -416,39 +459,48 @@ public class DefaultRedisList<E> extends AbstractRedisCollection<E> implements R
|
||||
// BlockingDeque
|
||||
//
|
||||
|
||||
@Override
|
||||
public boolean offerFirst(E e, long timeout, TimeUnit unit) throws InterruptedException {
|
||||
return offerFirst(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean offerLast(E e, long timeout, TimeUnit unit) throws InterruptedException {
|
||||
return offerLast(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException {
|
||||
return poll(timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E pollLast(long timeout, TimeUnit unit) throws InterruptedException {
|
||||
E element = listOps.rightPop(timeout, unit);
|
||||
return (element == null ? null : element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putFirst(E e) throws InterruptedException {
|
||||
add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putLast(E e) throws InterruptedException {
|
||||
put(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E takeFirst() throws InterruptedException {
|
||||
return take();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E takeLast() throws InterruptedException {
|
||||
return pollLast(0, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getType() {
|
||||
return DataType.LIST;
|
||||
}
|
||||
|
||||
@@ -47,14 +47,17 @@ public class DefaultRedisMap<K, V> implements RedisMap<K, V> {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public K getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V setValue(V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -79,26 +82,32 @@ public class DefaultRedisMap<K, V> implements RedisMap<K, V> {
|
||||
this.hashOps = boundOps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long increment(K key, long delta) {
|
||||
return hashOps.increment(key, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisOperations<String, ?> getOperations() {
|
||||
return hashOps.getOperations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
getOperations().delete(Collections.singleton(getKey()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
return hashOps.hasKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<java.util.Map.Entry<K, V>> entrySet() {
|
||||
Set<K> keySet = keySet();
|
||||
Collection<V> multiGet = hashOps.multiGet(keySet);
|
||||
@@ -114,38 +123,46 @@ public class DefaultRedisMap<K, V> implements RedisMap<K, V> {
|
||||
return entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(Object key) {
|
||||
return hashOps.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
return hashOps.keys();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V put(K key, V value) {
|
||||
V oldV = get(key);
|
||||
hashOps.put(key, value);
|
||||
return oldV;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> m) {
|
||||
hashOps.putAll(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
V v = get(key);
|
||||
hashOps.delete(key);
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return hashOps.size().intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
return hashOps.values();
|
||||
}
|
||||
@@ -177,6 +194,7 @@ public class DefaultRedisMap<K, V> implements RedisMap<K, V> {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V putIfAbsent(K key, V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -198,6 +216,7 @@ public class DefaultRedisMap<K, V> implements RedisMap<K, V> {
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object key, Object value) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -223,6 +242,7 @@ public class DefaultRedisMap<K, V> implements RedisMap<K, V> {
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replace(K key, V oldValue, V newValue) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -248,6 +268,7 @@ public class DefaultRedisMap<K, V> implements RedisMap<K, V> {
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public V replace(K key, V value) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -273,31 +294,38 @@ public class DefaultRedisMap<K, V> implements RedisMap<K, V> {
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expire(long timeout, TimeUnit unit) {
|
||||
return hashOps.expire(timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expireAt(Date date) {
|
||||
return hashOps.expireAt(date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getExpire() {
|
||||
return hashOps.getExpire();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean persist() {
|
||||
return hashOps.persist();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return hashOps.getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(String newKey) {
|
||||
hashOps.rename(newKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getType() {
|
||||
return hashOps.getType();
|
||||
}
|
||||
|
||||
@@ -68,56 +68,68 @@ public class DefaultRedisSet<E> extends AbstractRedisCollection<E> implements Re
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<E> diff(RedisSet<?> set) {
|
||||
return boundSetOps.diff(set.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> diff(Collection<? extends RedisSet<?>> sets) {
|
||||
return boundSetOps.diff(CollectionUtils.extractKeys(sets));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RedisSet<E> diffAndStore(RedisSet<?> set, String destKey) {
|
||||
boundSetOps.diffAndStore(set.getKey(), destKey);
|
||||
return new DefaultRedisSet<E>(boundSetOps.getOperations().boundSetOps(destKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisSet<E> diffAndStore(Collection<? extends RedisSet<?>> sets, String destKey) {
|
||||
boundSetOps.diffAndStore(CollectionUtils.extractKeys(sets), destKey);
|
||||
return new DefaultRedisSet<E>(boundSetOps.getOperations().boundSetOps(destKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> intersect(RedisSet<?> set) {
|
||||
return boundSetOps.intersect(set.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> intersect(Collection<? extends RedisSet<?>> sets) {
|
||||
return boundSetOps.intersect(CollectionUtils.extractKeys(sets));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisSet<E> intersectAndStore(RedisSet<?> set, String destKey) {
|
||||
boundSetOps.intersectAndStore(set.getKey(), destKey);
|
||||
return new DefaultRedisSet<E>(boundSetOps.getOperations().boundSetOps(destKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisSet<E> intersectAndStore(Collection<? extends RedisSet<?>> sets, String destKey) {
|
||||
boundSetOps.intersectAndStore(CollectionUtils.extractKeys(sets), destKey);
|
||||
return new DefaultRedisSet<E>(boundSetOps.getOperations().boundSetOps(destKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> union(RedisSet<?> set) {
|
||||
return boundSetOps.union(set.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> union(Collection<? extends RedisSet<?>> sets) {
|
||||
return boundSetOps.union(CollectionUtils.extractKeys(sets));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisSet<E> unionAndStore(RedisSet<?> set, String destKey) {
|
||||
boundSetOps.unionAndStore(set.getKey(), destKey);
|
||||
return new DefaultRedisSet<E>(boundSetOps.getOperations().boundSetOps(destKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisSet<E> unionAndStore(Collection<? extends RedisSet<?>> sets, String destKey) {
|
||||
boundSetOps.unionAndStore(CollectionUtils.extractKeys(sets), destKey);
|
||||
return new DefaultRedisSet<E>(boundSetOps.getOperations().boundSetOps(destKey));
|
||||
@@ -156,7 +168,8 @@ public class DefaultRedisSet<E> extends AbstractRedisCollection<E> implements Re
|
||||
return boundSetOps.size().intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getType() {
|
||||
return DataType.SET;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,43 +91,52 @@ public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements R
|
||||
this.defaultScore = defaultScore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisZSet<E> intersectAndStore(RedisZSet<?> set, String destKey) {
|
||||
boundZSetOps.intersectAndStore(set.getKey(), destKey);
|
||||
return new DefaultRedisZSet<E>(boundZSetOps.getOperations().boundZSetOps(destKey), getDefaultScore());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisZSet<E> intersectAndStore(Collection<? extends RedisZSet<?>> sets, String destKey) {
|
||||
boundZSetOps.intersectAndStore(CollectionUtils.extractKeys(sets), destKey);
|
||||
return new DefaultRedisZSet<E>(boundZSetOps.getOperations().boundZSetOps(destKey), getDefaultScore());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> range(long start, long end) {
|
||||
return boundZSetOps.range(start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> reverseRange(long start, long end) {
|
||||
return boundZSetOps.reverseRange(start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<E> rangeByScore(double min, double max) {
|
||||
return boundZSetOps.rangeByScore(min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisZSet<E> remove(long start, long end) {
|
||||
boundZSetOps.removeRange(start, end);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisZSet<E> removeByScore(double min, double max) {
|
||||
boundZSetOps.removeRangeByScore(min, max);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisZSet<E> unionAndStore(RedisZSet<?> set, String destKey) {
|
||||
boundZSetOps.unionAndStore(set.getKey(), destKey);
|
||||
return new DefaultRedisZSet<E>(boundZSetOps.getOperations().boundZSetOps(destKey), getDefaultScore());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisZSet<E> unionAndStore(Collection<? extends RedisZSet<?>> sets, String destKey) {
|
||||
boundZSetOps.unionAndStore(CollectionUtils.extractKeys(sets), destKey);
|
||||
return new DefaultRedisZSet<E>(boundZSetOps.getOperations().boundZSetOps(destKey), getDefaultScore());
|
||||
@@ -138,6 +147,7 @@ public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements R
|
||||
return add(e, getDefaultScore());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(E e, double score) {
|
||||
return boundZSetOps.add(e, score);
|
||||
}
|
||||
@@ -167,10 +177,12 @@ public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements R
|
||||
return boundZSetOps.size().intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getDefaultScore() {
|
||||
return defaultScore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E first() {
|
||||
Iterator<E> iterator = boundZSetOps.range(0, 0).iterator();
|
||||
if (iterator.hasNext())
|
||||
@@ -178,6 +190,7 @@ public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements R
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E last() {
|
||||
Iterator<E> iterator = boundZSetOps.reverseRange(0, 0).iterator();
|
||||
if (iterator.hasNext())
|
||||
@@ -185,18 +198,22 @@ public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements R
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long rank(Object o) {
|
||||
return boundZSetOps.rank(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long reverseRank(Object o) {
|
||||
return boundZSetOps.reverseRank(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double score(Object o) {
|
||||
return boundZSetOps.score(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getType() {
|
||||
return DataType.ZSET;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,9 @@ public class StubErrorHandler implements ErrorHandler {
|
||||
|
||||
public BlockingDeque<Throwable> throwables = new LinkedBlockingDeque<Throwable>();
|
||||
|
||||
@Override
|
||||
public void handleError(Throwable t) {
|
||||
throwables.add(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -196,6 +196,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
final BlockingDeque<Message> queue = new LinkedBlockingDeque<Message>();
|
||||
|
||||
final MessageListener ml = new MessageListener() {
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
queue.add(message);
|
||||
System.out.println("received message");
|
||||
@@ -211,12 +212,13 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
final AtomicBoolean flag = new AtomicBoolean(true);
|
||||
|
||||
Runnable listener = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
subConn.subscribe(ml, channel);
|
||||
System.out.println("Subscribed");
|
||||
while (flag.get()) {
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
Thread.currentThread().sleep(2000);
|
||||
} catch (Exception ex) {
|
||||
return;
|
||||
}
|
||||
@@ -249,6 +251,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
MessageListener listener = new MessageListener() {
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
assertArrayEquals(expectedChannel, message.getChannel());
|
||||
assertArrayEquals(expectedMessage, message.getBody());
|
||||
@@ -256,10 +259,11 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
};
|
||||
|
||||
Thread th = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// sleep 1 second to let the registration happen
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
Thread.currentThread().sleep(1000);
|
||||
} catch (InterruptedException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
@@ -284,6 +288,7 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
MessageListener listener = new MessageListener() {
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
assertArrayEquals(expectedPattern, pattern);
|
||||
assertArrayEquals(expectedMessage, message.getBody());
|
||||
@@ -292,10 +297,11 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
};
|
||||
|
||||
Thread th = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// sleep 1 second to let the registration happen
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
Thread.currentThread().sleep(1000);
|
||||
} catch (InterruptedException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public class SessionTest {
|
||||
final StringRedisTemplate template = new StringRedisTemplate(factory);
|
||||
|
||||
template.execute(new SessionCallback<Object>() {
|
||||
@Override
|
||||
public Object execute(RedisOperations operations) {
|
||||
checkConnection(template, conn);
|
||||
template.discard();
|
||||
@@ -49,6 +50,8 @@ public class SessionTest {
|
||||
|
||||
private void checkConnection(RedisTemplate<?, ?> template, final RedisConnection expectedConnection) {
|
||||
template.execute(new RedisCallback<Object>() {
|
||||
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) throws DataAccessException {
|
||||
assertSame(expectedConnection, connection);
|
||||
return null;
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.data.keyvalue.redis.connection.MessageListener;
|
||||
*/
|
||||
public class ThrowableMessageListener implements MessageListener {
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
throw new IllegalStateException("throwing exception for message " + message);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,8 @@ public abstract class AbstractRedisCollectionTests<T> {
|
||||
// remove the collection entirely since clear() doesn't always work
|
||||
collection.getOperations().delete(Collections.singleton(collection.getKey()));
|
||||
template.execute(new RedisCallback<Object>() {
|
||||
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.flushDb();
|
||||
return null;
|
||||
|
||||
@@ -92,6 +92,8 @@ public abstract class AbstractRedisMapTests<K, V> {
|
||||
// remove the collection entirely since clear() doesn't always work
|
||||
map.getOperations().delete(Collections.singleton(map.getKey()));
|
||||
template.execute(new RedisCallback<Object>() {
|
||||
|
||||
@Override
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.flushDb();
|
||||
return null;
|
||||
|
||||
@@ -27,6 +27,7 @@ public class PersonObjectFactory implements ObjectFactory<Person> {
|
||||
|
||||
private int counter = 0;
|
||||
|
||||
@Override
|
||||
public Person instance() {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
return new Person(uuid, uuid, ++counter, new Address(uuid, counter));
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.UUID;
|
||||
*/
|
||||
public class StringObjectFactory implements ObjectFactory<String> {
|
||||
|
||||
@Override
|
||||
public String instance() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user