diff --git a/pom.xml b/pom.xml
index 1a4c01c3e..82f6399a9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,8 +23,6 @@
2.2
4.2.2.Final
2.9.0
- 0.7
- 06052013
1.01
@@ -85,27 +83,6 @@
true
-
- org.jredis
- jredis-core-api
- ${jredis}
- true
-
-
-
- org.jredis
- jredis-core-ri
- ${jredis}
- true
-
-
-
- com.github.spullara.redis
- client
- ${srp}
- true
-
-
biz.paluch.redis
lettuce
diff --git a/src/main/asciidoc/reference/redis-transactions.adoc b/src/main/asciidoc/reference/redis-transactions.adoc
index 0976c4d7a..874232549 100644
--- a/src/main/asciidoc/reference/redis-transactions.adoc
+++ b/src/main/asciidoc/reference/redis-transactions.adoc
@@ -48,7 +48,7 @@ public class RedisTxContextConfiguration {
}
@Bean
- public RedisConnectionFactory redisConnectionFactory( // jedis, lettuce, srp,... );
+ public RedisConnectionFactory redisConnectionFactory( // jedis || lettuce);
@Bean
public DataSource dataSource() throws SQLException { // ... }
diff --git a/src/main/asciidoc/reference/redis.adoc b/src/main/asciidoc/reference/redis.adoc
index acdfd83c2..d68ee1218 100644
--- a/src/main/asciidoc/reference/redis.adoc
+++ b/src/main/asciidoc/reference/redis.adoc
@@ -12,7 +12,7 @@ Spring Data Redis provides easy configuration and access to Redis from Spring ap
[[redis:requirements]]
== Redis Requirements
-Spring Redis requires Redis 2.6 or above and Java SE 6.0 or above . In terms of language bindings (or connectors), Spring Redis integrates with http://github.com/xetorthio/jedis[Jedis], http://github.com/alphazero/jredis[JRedis] (Deprecated since 1.7), http://github.com/spullara/redis-protocol[SRP] (Deprecated since 1.7) and http://github.com/wg/lettuce[Lettuce], four popular open source Java libraries for Redis. If you are aware of any other connector that we should be integrating with please send us feedback.
+Spring Redis requires Redis 2.6 or above and Java SE 6.0 or above . In terms of language bindings (or connectors), Spring Redis integrates with http://github.com/xetorthio/jedis[Jedis] and http://github.com/mp911de/lettuce[Lettuce], four popular open source Java libraries for Redis. If you are aware of any other connector that we should be integrating with please send us feedback.
[[redis:architecture]]
== Redis Support High Level View
@@ -75,69 +75,6 @@ For production use however, one might want to tweak the settings such as the hos
----
-[[redis:connectors:jredis]]
-=== Configuring JRedis connector (Deprecated since 1.7)
-
-http://github.com/alphazero/jredis[JRedis] is another popular, open-source connector supported by Spring Data Redis through the `org.springframework.data.redis.connection.jredis` package.
-
-A typical JRedis configuration can looks like this:
-
-[source,xml]
-----
-
-
-
-
-
-
-----
-
-The configuration is quite similar to Jedis, with one notable exception. By default, the `JedisConnectionFactory` pools connections. In order to use a connection pool with JRedis, configure the `JredisConnectionFactory` with an instance of `JredisPool`. For example:
-
-[source,xml]
-----
-
-
-
-
-
-
-
-
-
-
-
-
-
-----
-
-[[redis:connectors:srp]]
-=== Configuring SRP connector (Deprecated since 1.7)
-
-https://github.com/spullara/redis-protocol[SRP] (an acronym for Sam's Redis Protocol) is the third open-source connector supported by Spring Data Redis through the `org.springframework.data.redis.connection.srp` package.
-
-By now, its configuration is probably easy to guess:
-
-[source,xml]
-----
-
-
-
-
-
-
-----
-
-Needless to say, the configuration is quite similar to that of the other connectors.
-
[[redis:connectors:lettuce]]
=== Configuring Lettuce connector
diff --git a/src/main/java/org/springframework/data/redis/connection/ConnectionUtils.java b/src/main/java/org/springframework/data/redis/connection/ConnectionUtils.java
index 9ba1ccca8..1ff418c6e 100644
--- a/src/main/java/org/springframework/data/redis/connection/ConnectionUtils.java
+++ b/src/main/java/org/springframework/data/redis/connection/ConnectionUtils.java
@@ -16,9 +16,7 @@
package org.springframework.data.redis.connection;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
-import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
-import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
/**
* Utilities for examining a {@link RedisConnection}
@@ -29,16 +27,7 @@ import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
public abstract class ConnectionUtils {
public static boolean isAsync(RedisConnectionFactory connectionFactory) {
- return (connectionFactory instanceof LettuceConnectionFactory)
- || (connectionFactory instanceof SrpConnectionFactory);
- }
-
- public static boolean isSrp(RedisConnectionFactory connectionFactory) {
- return connectionFactory instanceof SrpConnectionFactory;
- }
-
- public static boolean isJredis(RedisConnectionFactory connectionFactory) {
- return connectionFactory instanceof JredisConnectionFactory;
+ return (connectionFactory instanceof LettuceConnectionFactory);
}
public static boolean isLettuce(RedisConnectionFactory connectionFactory) {
diff --git a/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnection.java b/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnection.java
deleted file mode 100644
index 155dcab68..000000000
--- a/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnection.java
+++ /dev/null
@@ -1,1643 +0,0 @@
-/*
- * Copyright 2011-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.data.redis.connection.jredis;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import org.jredis.ClientRuntimeException;
-import org.jredis.JRedis;
-import org.jredis.Query.Support;
-import org.jredis.RedisException;
-import org.jredis.Sort;
-import org.jredis.connector.ConnectionException;
-import org.jredis.connector.NotConnectedException;
-import org.jredis.protocol.Command;
-import org.jredis.ri.alphazero.JRedisSupport;
-import org.springframework.dao.DataAccessException;
-import org.springframework.data.geo.Circle;
-import org.springframework.data.geo.Distance;
-import org.springframework.data.geo.GeoResults;
-import org.springframework.data.geo.Metric;
-import org.springframework.data.geo.Point;
-import org.springframework.data.redis.RedisSystemException;
-import org.springframework.data.redis.connection.AbstractRedisConnection;
-import org.springframework.data.redis.connection.DataType;
-import org.springframework.data.redis.connection.MessageListener;
-import org.springframework.data.redis.connection.Pool;
-import org.springframework.data.redis.connection.RedisNode;
-import org.springframework.data.redis.connection.ReturnType;
-import org.springframework.data.redis.connection.SortParameters;
-import org.springframework.data.redis.connection.Subscription;
-import org.springframework.data.redis.connection.convert.Converters;
-import org.springframework.data.redis.core.Cursor;
-import org.springframework.data.redis.core.ScanOptions;
-import org.springframework.data.redis.core.types.Expiration;
-import org.springframework.data.redis.core.types.RedisClientInfo;
-import org.springframework.util.Assert;
-import org.springframework.util.ObjectUtils;
-import org.springframework.util.ReflectionUtils;
-
-/**
- * {@code RedisConnection} implementation on top of JRedis library.
- *
- * @author Costin Leau
- * @author Jennifer Hickey
- * @author Christoph Strobl
- * @author Thomas Darimont
- * @author David Liu
- * @author Ninad Divadkar
- * @author Mark Paluch
- * @deprecated since 1.7. Will be removed in subsequent version.
- */
-@Deprecated
-public class JredisConnection extends AbstractRedisConnection {
-
- private static final Method SERVICE_REQUEST;
-
- private final JRedis jredis;
- private final Pool pool;
- private boolean isClosed = false;
- /** flag indicating whether the connection needs to be dropped or not */
- private boolean broken = false;
-
- static {
- SERVICE_REQUEST = ReflectionUtils.findMethod(JRedisSupport.class, "serviceRequest", Command.class, byte[][].class);
- ReflectionUtils.makeAccessible(SERVICE_REQUEST);
- }
-
- /**
- * Constructs a new JredisConnection instance.
- *
- * @param jredis JRedis connection
- */
- public JredisConnection(JRedis jredis) {
- this(jredis, null);
- }
-
- public JredisConnection(JRedis jredis, Pool pool) {
- Assert.notNull(jredis, "a not-null instance required");
- this.jredis = jredis;
- this.pool = pool;
- }
-
- protected DataAccessException convertJredisAccessException(Exception ex) {
- if (ex instanceof RedisException) {
- return JredisUtils.convertJredisAccessException((RedisException) ex);
- }
-
- if (ex instanceof ClientRuntimeException) {
- if (ex instanceof NotConnectedException || ex instanceof ConnectionException) {
- broken = true;
- }
- return JredisUtils.convertJredisAccessException((ClientRuntimeException) ex);
- }
-
- return new RedisSystemException("Unknown JRedis exception", ex);
- }
-
- public Object execute(String command, byte[]... args) {
- Assert.hasText(command, "a valid command needs to be specified");
- try {
- List mArgs = new ArrayList();
- if (!ObjectUtils.isEmpty(args)) {
- Collections.addAll(mArgs, args);
- }
-
- return ReflectionUtils.invokeMethod(SERVICE_REQUEST, jredis, Command.valueOf(command.trim().toUpperCase()),
- mArgs.toArray(new byte[mArgs.size()][]));
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void close() throws RedisSystemException {
- super.close();
-
- if (isClosed()) {
- return;
- }
- isClosed = true;
-
- if (pool != null) {
- if (!broken) {
- pool.returnResource(jredis);
- } else {
- pool.returnBrokenResource(jredis);
- }
- return;
- }
-
- try {
- jredis.quit();
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
-
- }
-
- public JRedis getNativeConnection() {
- return jredis;
- }
-
- public boolean isClosed() {
- return isClosed;
- }
-
- public boolean isQueueing() {
- return false;
- }
-
- public boolean isPipelined() {
- return false;
- }
-
- public void openPipeline() {
- throw new UnsupportedOperationException("Pipelining not supported by JRedis");
- }
-
- public List closePipeline() {
- return Collections.emptyList();
- }
-
- public List sort(byte[] key, SortParameters params) {
- Sort sort = jredis.sort(key);
- JredisUtils.applySortingParams(sort, params, null);
- try {
- return sort.exec();
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long sort(byte[] key, SortParameters params, byte[] storeKey) {
- Sort sort = jredis.sort(key);
- JredisUtils.applySortingParams(sort, params, storeKey);
- try {
- return Support.unpackValue(sort.exec());
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long dbSize() {
- try {
- return (Long) jredis.dbsize();
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void flushDb() {
- try {
- jredis.flushdb();
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void flushAll() {
- try {
- jredis.flushall();
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public byte[] echo(byte[] message) {
- try {
- return jredis.echo(message);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public String ping() {
- try {
- jredis.ping();
- return "PONG";
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void bgSave() {
- try {
- jredis.bgsave();
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void bgReWriteAof() {
- try {
- jredis.bgrewriteaof();
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- /**
- * @deprecated As of 1.3, use {@link #bgReWriteAof}.
- */
- @Deprecated
- public void bgWriteAof() {
- bgReWriteAof();
- }
-
- public void save() {
- try {
- jredis.save();
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public List getConfig(String pattern) {
- throw new UnsupportedOperationException();
- }
-
- public Properties info() {
- try {
- return JredisUtils.info(jredis.info());
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Properties info(String section) {
- throw new UnsupportedOperationException();
- }
-
- public Long lastSave() {
- try {
- return (Long) jredis.lastsave();
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void setConfig(String param, String value) {
- throw new UnsupportedOperationException();
- }
-
- public void resetConfigStats() {
- throw new UnsupportedOperationException();
- }
-
- public void shutdown() {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisServerCommands#shutdown(org.springframework.data.redis.connection.RedisServerCommands.ShutdownOption)
- */
- @Override
- public void shutdown(ShutdownOption option) {
- throw new UnsupportedOperationException();
- }
-
- public Long del(byte[]... keys) {
- try {
- return jredis.del(keys);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void discard() {
- try {
- jredis.discard();
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public List exec() {
- throw new UnsupportedOperationException();
- }
-
- public Boolean exists(byte[] key) {
- try {
- return jredis.exists(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Boolean expire(byte[] key, long seconds) {
- try {
- return jredis.expire(key, (int) seconds);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Boolean expireAt(byte[] key, long unixTime) {
- try {
- return jredis.expireat(key, unixTime);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Boolean pExpire(byte[] key, long millis) {
- throw new UnsupportedOperationException();
- }
-
- public Boolean pExpireAt(byte[] key, long unixTimeInMillis) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisKeyCommands#pTtl(byte[])
- */
- @Override
- public Long pTtl(byte[] key) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisKeyCommands#pTtl(byte[], java.util.concurrent.TimeUnit)
- */
- @Override
- public Long pTtl(byte[] key, TimeUnit timeUnit) {
- throw new UnsupportedOperationException();
- }
-
- public byte[] dump(byte[] key) {
- throw new UnsupportedOperationException();
- }
-
- public void restore(byte[] key, long ttlInMillis, byte[] serializedValue) {
- throw new UnsupportedOperationException();
- }
-
- public Set keys(byte[] pattern) {
- try {
- return new LinkedHashSet(jredis.keys(pattern));
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void multi() {
- throw new UnsupportedOperationException();
- }
-
- public Boolean persist(byte[] key) {
- throw new UnsupportedOperationException();
- }
-
- public Boolean move(byte[] key, int dbIndex) {
- try {
- return jredis.move(key, dbIndex);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public byte[] randomKey() {
- try {
- return jredis.randomkey();
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void rename(byte[] oldName, byte[] newName) {
- try {
- jredis.rename(oldName, newName);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Boolean renameNX(byte[] oldName, byte[] newName) {
- try {
- return jredis.renamenx(oldName, newName);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void select(int dbIndex) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisKeyCommands#ttl(byte[])
- */
- @Override
- public Long ttl(byte[] key) {
-
- Assert.notNull(key, "Key must not be null!");
-
- try {
- return jredis.ttl(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisKeyCommands#ttl(byte[], java.util.concurrent.TimeUnit)
- */
- @Override
- public Long ttl(byte[] key, TimeUnit timeUnit) {
-
- Assert.notNull(key, "Key must not be null!");
-
- try {
- return Converters.secondsToTimeUnit(jredis.ttl(key), timeUnit);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public DataType type(byte[] key) {
- try {
- return JredisUtils.convertDataType(jredis.type(key));
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void unwatch() {
- throw new UnsupportedOperationException();
- }
-
- public void watch(byte[]... keys) {
- throw new UnsupportedOperationException();
- }
-
- //
- // String operations
- //
-
- public byte[] get(byte[] key) {
- try {
- return jredis.get(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void set(byte[] key, byte[] value) {
- try {
- jredis.set(key, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisStringCommands#set(byte[], byte[], org.springframework.data.redis.core.types.Expiration, org.springframework.data.redis.connection.RedisStringCommands.SetOption)
- */
- @Override
- public void set(byte[] key, byte[] value, Expiration expiration, SetOption option) {
- throw new UnsupportedOperationException(
- "SET with options is not supported for JRedis. Please use SETNX, SETEX, PSETEX.");
- }
-
- public byte[] getSet(byte[] key, byte[] value) {
- try {
- return jredis.getset(key, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long append(byte[] key, byte[] value) {
- try {
- return jredis.append(key, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public List mGet(byte[]... keys) {
- try {
- return jredis.mget(keys);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void mSet(Map tuple) {
- try {
- jredis.mset(tuple);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Boolean mSetNX(Map tuple) {
- try {
- return jredis.msetnx(tuple);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void setEx(byte[] key, long seconds, byte[] value) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisStringCommands#pSetEx(byte[], long, byte[])
- */
- @Override
- public void pSetEx(byte[] key, long milliseconds, byte[] value) {
- throw new UnsupportedOperationException();
- }
-
- public Boolean setNX(byte[] key, byte[] value) {
- try {
- return jredis.setnx(key, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public byte[] getRange(byte[] key, long start, long end) {
- try {
- return jredis.substr(key, start, end);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long decr(byte[] key) {
- try {
- return jredis.decr(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long decrBy(byte[] key, long value) {
- try {
- return jredis.decrby(key, (int) value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long incr(byte[] key) {
- try {
- return jredis.incr(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long incrBy(byte[] key, long value) {
- try {
- return jredis.incrby(key, (int) value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Double incrBy(byte[] key, double value) {
- throw new UnsupportedOperationException();
- }
-
- public Boolean getBit(byte[] key, long offset) {
- try {
- return jredis.getbit(key, (int) offset);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Boolean setBit(byte[] key, long offset, boolean value) {
- try {
- return jredis.setbit(key, (int) offset, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void setRange(byte[] key, byte[] value, long start) {
- throw new UnsupportedOperationException();
- }
-
- public Long strLen(byte[] key) {
- throw new UnsupportedOperationException();
- }
-
- public Long bitCount(byte[] key) {
- throw new UnsupportedOperationException();
- }
-
- public Long bitCount(byte[] key, long begin, long end) {
- throw new UnsupportedOperationException();
- }
-
- public Long bitOp(BitOperation op, byte[] destination, byte[]... keys) {
- throw new UnsupportedOperationException();
- }
-
- //
- // List commands
- //
-
- public List bLPop(int timeout, byte[]... keys) {
- throw new UnsupportedOperationException();
- }
-
- public List bRPop(int timeout, byte[]... keys) {
- throw new UnsupportedOperationException();
- }
-
- public byte[] lIndex(byte[] key, long index) {
- try {
- return jredis.lindex(key, index);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long lLen(byte[] key) {
- try {
- return jredis.llen(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public byte[] lPop(byte[] key) {
- try {
- return jredis.lpop(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long lPush(byte[] key, byte[]... values) {
- if (values.length > 1) {
- throw new UnsupportedOperationException("lPush of multiple fields not supported");
- }
- try {
- jredis.lpush(key, values[0]);
- return null;
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public List lRange(byte[] key, long start, long end) {
- try {
- List lrange = jredis.lrange(key, start, end);
-
- return lrange;
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long lRem(byte[] key, long count, byte[] value) {
- try {
- return jredis.lrem(key, value, (int) count);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void lSet(byte[] key, long index, byte[] value) {
- try {
- jredis.lset(key, index, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public void lTrim(byte[] key, long start, long end) {
- try {
- jredis.ltrim(key, start, end);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public byte[] rPop(byte[] key) {
- try {
- return jredis.rpop(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public byte[] rPopLPush(byte[] srcKey, byte[] dstKey) {
- try {
- return jredis.rpoplpush(srcKey, dstKey);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long rPush(byte[] key, byte[]... values) {
- if (values.length > 1) {
- throw new UnsupportedOperationException("rPush of multiple fields not supported");
- }
- try {
- jredis.rpush(key, values[0]);
- return null;
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long lInsert(byte[] key, Position where, byte[] pivot, byte[] value) {
- throw new UnsupportedOperationException();
- }
-
- public byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey) {
- throw new UnsupportedOperationException();
- }
-
- public Long lPushX(byte[] key, byte[] value) {
- throw new UnsupportedOperationException();
- }
-
- public Long rPushX(byte[] key, byte[] value) {
- throw new UnsupportedOperationException();
- }
-
- //
- // Set commands
- //
-
- public Long sAdd(byte[] key, byte[]... values) {
- if (values.length > 1) {
- throw new UnsupportedOperationException("sAdd of multiple fields not supported");
- }
- try {
- return JredisUtils.toLong(jredis.sadd(key, values[0]));
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long sCard(byte[] key) {
- try {
- return jredis.scard(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Set sDiff(byte[]... keys) {
- byte[] destKey = keys[0];
- byte[][] sets = Arrays.copyOfRange(keys, 1, keys.length);
-
- try {
- List result = jredis.sdiff(destKey, sets);
- return new LinkedHashSet(result);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long sDiffStore(byte[] destKey, byte[]... keys) {
- try {
- jredis.sdiffstore(destKey, keys);
- return Long.valueOf(-1);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Set sInter(byte[]... keys) {
- byte[] set1 = keys[0];
- byte[][] sets = Arrays.copyOfRange(keys, 1, keys.length);
-
- try {
- List result = jredis.sinter(set1, sets);
- return new LinkedHashSet(result);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long sInterStore(byte[] destKey, byte[]... keys) {
- try {
- jredis.sinterstore(destKey, keys);
- return Long.valueOf(-1);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Boolean sIsMember(byte[] key, byte[] value) {
- try {
- return jredis.sismember(key, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Set sMembers(byte[] key) {
- try {
- return new LinkedHashSet(jredis.smembers(key));
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Boolean sMove(byte[] srcKey, byte[] destKey, byte[] value) {
- try {
- return jredis.smove(srcKey, destKey, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public byte[] sPop(byte[] key) {
- try {
- return jredis.spop(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public byte[] sRandMember(byte[] key) {
- try {
- return jredis.srandmember(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public List sRandMember(byte[] key, long count) {
- throw new UnsupportedOperationException();
- }
-
- public Long sRem(byte[] key, byte[]... values) {
- if (values.length > 1) {
- throw new UnsupportedOperationException("sRem of multiple fields not supported");
- }
- try {
- return JredisUtils.toLong(jredis.srem(key, values[0]));
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Set sUnion(byte[]... keys) {
- byte[] set1 = keys[0];
- byte[][] sets = Arrays.copyOfRange(keys, 1, keys.length);
-
- try {
- return new LinkedHashSet(jredis.sunion(set1, sets));
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long sUnionStore(byte[] destKey, byte[]... keys) {
- try {
- jredis.sunionstore(destKey, keys);
- return Long.valueOf(-1);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- //
- // ZSet commands
- //
-
- public Boolean zAdd(byte[] key, double score, byte[] value) {
- try {
- return jredis.zadd(key, score, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long zAdd(byte[] key, Set tuples) {
- throw new UnsupportedOperationException();
- }
-
- public Long zCard(byte[] key) {
- try {
- return jredis.zcard(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long zCount(byte[] key, double min, double max) {
- return zCount(key, new Range().gte(min).lte(max));
- }
-
- @Override
- public Long zCount(byte[] key, Range range) {
-
- Assert.notNull(range, "Range for ZCOUNT must not be null!");
-
- double min = ((Double) range.getMin().getValue()).doubleValue();
- double max = ((Double) range.getMax().getValue()).doubleValue();
-
- try {
- return jredis.zcount(key, min, max);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Double zIncrBy(byte[] key, double increment, byte[] value) {
- try {
- return jredis.zincrby(key, increment, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long zInterStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
- throw new UnsupportedOperationException();
- }
-
- public Long zInterStore(byte[] destKey, byte[]... sets) {
- throw new UnsupportedOperationException();
- }
-
- public Set zRange(byte[] key, long start, long end) {
- try {
- return new LinkedHashSet(jredis.zrange(key, start, end));
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Set zRangeWithScores(byte[] key, long start, long end) {
- throw new UnsupportedOperationException();
- }
-
- public Set zRangeByScore(byte[] key, double min, double max) {
- try {
- return new LinkedHashSet(jredis.zrangebyscore(key, min, max));
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Set zRangeByScoreWithScores(byte[] key, double min, double max) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Set zRangeByScoreWithScores(byte[] key, Range range) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Set zRangeByScoreWithScores(byte[] key, Range range, Limit limit) {
- throw new UnsupportedOperationException();
- }
-
- public Set zRangeByScore(byte[] key, double min, double max, long offset, long count) {
- throw new UnsupportedOperationException();
- }
-
- public Set zRangeByScoreWithScores(byte[] key, double min, double max, long offset, long count) {
- throw new UnsupportedOperationException();
- }
-
- public Set zRevRangeByScore(byte[] key, double min, double max, long offset, long count) {
- throw new UnsupportedOperationException();
- }
-
- public Set zRevRangeByScore(byte[] key, double min, double max) {
- throw new UnsupportedOperationException();
- }
-
- public Set zRevRangeByScoreWithScores(byte[] key, double min, double max, long offset, long count) {
- throw new UnsupportedOperationException();
- }
-
- public Set zRevRangeByScoreWithScores(byte[] key, double min, double max) {
- throw new UnsupportedOperationException();
- }
-
- public Long zRank(byte[] key, byte[] value) {
- try {
- return jredis.zrank(key, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long zRem(byte[] key, byte[]... values) {
- if (values.length > 1) {
- throw new UnsupportedOperationException("zRem of multiple fields not supported");
- }
- try {
- return JredisUtils.toLong(jredis.zrem(key, values[0]));
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long zRemRange(byte[] key, long start, long end) {
- try {
- return jredis.zremrangebyrank(key, start, end);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long zRemRangeByScore(byte[] key, double min, double max) {
- try {
- return jredis.zremrangebyscore(key, min, max);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Set zRevRange(byte[] key, long start, long end) {
- try {
- return new LinkedHashSet(jredis.zrevrange(key, start, end));
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Set zRevRangeWithScores(byte[] key, long start, long end) {
- throw new UnsupportedOperationException();
- }
-
- public Long zRevRank(byte[] key, byte[] value) {
- try {
- return jredis.zrevrank(key, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Double zScore(byte[] key, byte[] value) {
- try {
- return jredis.zscore(key, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- //
- // Hash commands
- //
-
- public Long zUnionStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
- throw new UnsupportedOperationException();
- }
-
- public Long zUnionStore(byte[] destKey, byte[]... sets) {
- throw new UnsupportedOperationException();
- }
-
- public Long hDel(byte[] key, byte[]... fields) {
- if (fields.length > 1) {
- throw new UnsupportedOperationException("hDel of multiple fields not supported");
- }
- try {
- return JredisUtils.toLong(jredis.hdel(key, fields[0]));
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Boolean hExists(byte[] key, byte[] field) {
- try {
- return jredis.hexists(key, field);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public byte[] hGet(byte[] key, byte[] field) {
- try {
- return jredis.hget(key, field);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Map hGetAll(byte[] key) {
- try {
- return jredis.hgetall(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long hIncrBy(byte[] key, byte[] field, long delta) {
- throw new UnsupportedOperationException();
- }
-
- public Double hIncrBy(byte[] key, byte[] field, double delta) {
- throw new UnsupportedOperationException();
- }
-
- public Set hKeys(byte[] key) {
- try {
- return new LinkedHashSet(jredis.hkeys(key));
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Long hLen(byte[] key) {
- try {
- return jredis.hlen(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public List hMGet(byte[] key, byte[]... fields) {
- throw new UnsupportedOperationException();
- }
-
- public void hMSet(byte[] key, Map values) {
- throw new UnsupportedOperationException();
- }
-
- public Boolean hSet(byte[] key, byte[] field, byte[] value) {
- try {
- return jredis.hset(key, field, value);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- public Boolean hSetNX(byte[] key, byte[] field, byte[] value) {
- throw new UnsupportedOperationException();
- }
-
- public List hVals(byte[] key) {
- try {
- return jredis.hvals(key);
- } catch (Exception ex) {
- throw convertJredisAccessException(ex);
- }
- }
-
- //
- // PubSub commands
- //
-
- public Subscription getSubscription() {
- return null;
- }
-
- public boolean isSubscribed() {
- return false;
- }
-
- public void pSubscribe(MessageListener listener, byte[]... patterns) {
- throw new UnsupportedOperationException();
- }
-
- public Long publish(byte[] channel, byte[] message) {
- throw new UnsupportedOperationException();
- }
-
- public void subscribe(MessageListener listener, byte[]... channels) {
- throw new UnsupportedOperationException();
- }
-
- //
- // Geo commands
- //
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoAdd(byte[], org.springframework.data.geo.Point, byte[])
- */
- @Override
- public Long geoAdd(byte[] key, Point point, byte[] member) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoAdd(byte[], org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation)
- */
- @Override
- public Long geoAdd(byte[] key, GeoLocation location) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoAdd(byte[], java.util.Map)
- */
- @Override
- public Long geoAdd(byte[] key, Map memberCoordinateMap) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoAdd(byte[], java.lang.Iterable)
- */
- @Override
- public Long geoAdd(byte[] key, Iterable> locations) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoDist(byte[], byte[], byte[])
- */
- @Override
- public Distance geoDist(byte[] key, byte[] member1, byte[] member2) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoDist(byte[], byte[], byte[], org.springframework.data.geo.Metric)
- */
- @Override
- public Distance geoDist(byte[] key, byte[] member1, byte[] member2, Metric metric) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoHash(byte[], byte[][])
- */
- @Override
- public List geoHash(byte[] key, byte[]... members) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoPos(byte[], byte[][])
- */
- @Override
- public List geoPos(byte[] key, byte[]... members) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoRadius(byte[], org.springframework.data.geo.Circle)
- */
- @Override
- public GeoResults> geoRadius(byte[] key, Circle within) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoRadius(byte[], org.springframework.data.geo.Circle, org.springframework.data.redis.core.GeoRadiusCommandArgs)
- */
- @Override
- public GeoResults> geoRadius(byte[] key, Circle within, GeoRadiusCommandArgs args) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoRadiusByMember(byte[], byte[], double)
- */
- @Override
- public GeoResults> geoRadiusByMember(byte[] key, byte[] member, double radius) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoRadiusByMember(byte[], byte[], org.springframework.data.geo.Distance)
- */
- @Override
- public GeoResults> geoRadiusByMember(byte[] key, byte[] member, Distance radius) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoRadiusByMember(byte[], byte[], org.springframework.data.geo.Distance, org.springframework.data.redis.core.GeoRadiusCommandArgs)
- */
- @Override
- public GeoResults> geoRadiusByMember(byte[] key, byte[] member, Distance radius,
- GeoRadiusCommandArgs args) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoRemove(byte[], byte[][])
- */
- @Override
- public Long geoRemove(byte[] key, byte[]... members) {
- throw new UnsupportedOperationException();
- }
-
- //
- // Scripting commands
- //
-
- public void scriptFlush() {
- throw new UnsupportedOperationException();
- }
-
- public void scriptKill() {
- throw new UnsupportedOperationException();
- }
-
- public String scriptLoad(byte[] script) {
- throw new UnsupportedOperationException();
- }
-
- public List scriptExists(String... scriptSha1) {
- throw new UnsupportedOperationException();
- }
-
- public T eval(byte[] script, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
- throw new UnsupportedOperationException();
- }
-
- public T evalSha(String scriptSha1, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
- throw new UnsupportedOperationException();
- }
-
- public T evalSha(byte[] scriptSha1, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisServerCommands#time()
- */
- @Override
- public Long time() {
- throw new UnsupportedOperationException("The 'TIME' command is not supported by the JRedis driver.");
- }
-
- @Override
- public void killClient(String host, int port) {
- throw new UnsupportedOperationException("The 'CLIENT KILL' command is not supported by the JRedis driver.");
- }
-
- @Override
- public void setClientName(byte[] name) {
- throw new UnsupportedOperationException("'CLIENT SETNAME' is not supported by the JRedis driver.");
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisServerCommands#slaveOf(java.lang.String, int)
- */
- @Override
- public void slaveOf(String host, int port) {
-
- try {
- this.jredis.slaveof(host, port);
- } catch (Exception e) {
- throw convertJredisAccessException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisServerCommands#getClientName()
- */
- @Override
- public String getClientName() {
- throw new UnsupportedOperationException("The 'CLIENT GETNAME' command is not supported by the JRedis driver.");
- }
-
- public List getClientList() {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.springframework.data.redis.connection.RedisServerCommands#slaveOfNoOne()
- */
- @Override
- public void slaveOfNoOne() {
-
- try {
- this.jredis.slaveofnone();
- } catch (Exception e) {
- throw convertJredisAccessException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisKeyCommands#scan(org.springframework.data.redis.core.ScanOptions)
- */
- @Override
- public Cursor scan(ScanOptions options) {
- throw new UnsupportedOperationException("'SCAN' command is not supported for jredis.");
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zScan(byte[], org.springframework.data.redis.core.ScanOptions)
- */
- @Override
- public Cursor zScan(byte[] key, ScanOptions options) {
- throw new UnsupportedOperationException("'ZSCAN' command is not supported for jredis.");
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisSetCommands#sScan(byte[], org.springframework.data.redis.core.ScanOptions)
- */
- @Override
- public Cursor sScan(byte[] key, ScanOptions options) {
- throw new UnsupportedOperationException("'SSCAN' command is not uspported for jredis");
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisHashCommands#hscan(byte[], org.springframework.data.redis.core.ScanOptions)
- */
- @Override
- public Cursor> hScan(byte[] key, ScanOptions options) {
- throw new UnsupportedOperationException("'HSCAN' command is not uspported for jredis");
- }
-
- @Override
- public Set zRangeByScore(byte[] key, String min, String max) {
- throw new UnsupportedOperationException("'zRangeByScore' command is not uspported for jredis");
- }
-
- @Override
- public Set zRangeByScore(byte[] key, String min, String max, long offset, long count) {
- throw new UnsupportedOperationException("'zRangeByScore' command is not uspported for jredis");
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.HyperLogLogCommands#pfAdd(byte[], byte[][])
- */
- @Override
- public Long pfAdd(byte[] key, byte[]... values) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.HyperLogLogCommands#pfCount(byte[][])
- */
- @Override
- public Long pfCount(byte[]... keys) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.HyperLogLogCommands#pfMerge(byte[], byte[][])
- */
- @Override
- public void pfMerge(byte[] destinationKey, byte[]... sourceKeys) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zRangeByLex(byte[])
- */
- @Override
- public Set zRangeByLex(byte[] key) {
- throw new UnsupportedOperationException("ZRANGEBYLEX is no supported for jredis.");
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zRangeByLex(byte[], org.springframework.data.redis.connection.RedisZSetCommands.Range)
- */
- @Override
- public Set zRangeByLex(byte[] key, Range range) {
- throw new UnsupportedOperationException("ZRANGEBYLEX is no supported for jredis.");
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zRangeByLex(byte[], org.springframework.data.redis.connection.RedisZSetCommands.Range, org.springframework.data.redis.connection.RedisZSetCommands.Limit)
- */
- @Override
- public Set zRangeByLex(byte[] key, Range range, Limit limit) {
- throw new UnsupportedOperationException("ZRANGEBYLEX is no supported for jredis.");
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zRevRangeByScore(byte[], org.springframework.data.redis.connection.RedisZSetCommands.Range)
- */
- @Override
- public Set zRevRangeByScore(byte[] key, Range range) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zRevRangeByScore(byte[], org.springframework.data.redis.connection.RedisZSetCommands.Range, org.springframework.data.redis.connection.RedisZSetCommands.Limit)
- */
- @Override
- public Set zRevRangeByScore(byte[] key, Range range, Limit limit) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zRevRangeByScoreWithScores(byte[], org.springframework.data.redis.connection.RedisZSetCommands.Range, org.springframework.data.redis.connection.RedisZSetCommands.Limit)
- */
- @Override
- public Set zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zRemRangeByScore(byte[], org.springframework.data.redis.connection.RedisZSetCommands.Range)
- */
- @Override
- public Long zRemRangeByScore(byte[] key, Range range) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zRangeByScore(byte[], org.springframework.data.redis.connection.RedisZSetCommands.Range)
- */
- @Override
- public Set zRangeByScore(byte[] key, Range range) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zRangeByScore(byte[], org.springframework.data.redis.connection.RedisZSetCommands.Range, org.springframework.data.redis.connection.RedisZSetCommands.Limit)
- */
- @Override
- public Set zRangeByScore(byte[] key, Range range, Limit limit) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zRevRangeByScoreWithScores(byte[], org.springframework.data.redis.connection.RedisZSetCommands.Range)
- */
- @Override
- public Set zRevRangeByScoreWithScores(byte[] key, Range range) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisServerCommands#migrate(byte[], org.springframework.data.redis.connection.RedisNode, int, org.springframework.data.redis.connection.RedisServerCommands.MigrateOption)
- */
- @Override
- public void migrate(byte[] key, RedisNode target, int dbIndex, MigrateOption option) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisServerCommands#migrate(byte[], org.springframework.data.redis.connection.RedisNode, int, org.springframework.data.redis.connection.RedisServerCommands.MigrateOption, long)
- */
- @Override
- public void migrate(byte[] key, RedisNode target, int dbIndex, MigrateOption option, long timeout) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnectionFactory.java b/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnectionFactory.java
deleted file mode 100644
index 2ed153a6f..000000000
--- a/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnectionFactory.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright 2011-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.data.redis.connection.jredis;
-
-import org.jredis.ClientRuntimeException;
-import org.jredis.JRedis;
-import org.jredis.connector.Connection;
-import org.jredis.connector.Connection.Socket.Property;
-import org.jredis.connector.ConnectionSpec;
-import org.jredis.ri.alphazero.JRedisClient;
-import org.jredis.ri.alphazero.connection.DefaultConnectionSpec;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.dao.DataAccessException;
-import org.springframework.data.redis.connection.Pool;
-import org.springframework.data.redis.connection.RedisClusterConnection;
-import org.springframework.data.redis.connection.RedisConnection;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.connection.RedisSentinelConnection;
-import org.springframework.util.Assert;
-import org.springframework.util.StringUtils;
-
-/**
- * Connection factory using creating JRedis based connections.
- *
- * @author Costin Leau
- * @author Jennifer Hickey
- * @deprecated since 1.7. Will be removed in subsequent version.
- */
-@Deprecated
-public class JredisConnectionFactory implements InitializingBean, DisposableBean, RedisConnectionFactory {
-
- private ConnectionSpec connectionSpec;
-
- private String hostName = "localhost";
- private int port = DEFAULT_REDIS_PORT;
- private String password = null;
- private int timeout;
- private int dbIndex = DEFAULT_REDIS_DB;
- private Pool pool;
-
- private static final int DEFAULT_REDIS_PORT = 6379;
- private static final int DEFAULT_REDIS_DB = 0;
- private static final byte[] DEFAULT_REDIS_PASSWORD = null;
-
- /**
- * Constructs a new JredisConnectionFactory instance.
- */
- public JredisConnectionFactory() {}
-
- /**
- * Constructs a new JredisConnectionFactory instance. Will override the other connection parameters
- * passed to the factory.
- *
- * @param connectionSpec already configured connection.
- */
- public JredisConnectionFactory(ConnectionSpec connectionSpec) {
- this.connectionSpec = connectionSpec;
- }
-
- public JredisConnectionFactory(Pool pool) {
- this.pool = pool;
- }
-
- public void afterPropertiesSet() {
- if (connectionSpec == null && pool == null) {
- Assert.hasText(hostName);
- connectionSpec = DefaultConnectionSpec.newSpec(hostName, port, dbIndex, DEFAULT_REDIS_PASSWORD);
- connectionSpec.setConnectionFlag(Connection.Flag.RELIABLE, false);
-
- if (StringUtils.hasLength(password)) {
- connectionSpec.setCredentials(password);
- }
-
- if (timeout > 0) {
- connectionSpec.setSocketProperty(Property.SO_TIMEOUT, timeout);
- }
- }
- }
-
- public void destroy() throws Exception {
- if (pool != null) {
- pool.destroy();
- pool = null;
- }
- }
-
- public RedisConnection getConnection() {
- JredisConnection connection;
- if (pool != null) {
- connection = new JredisConnection(pool.getResource(), pool);
- } else {
- connection = new JredisConnection(new JRedisClient(connectionSpec), null);
- }
- return postProcessConnection(connection);
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisConnectionFactory#getClusterConnection()
- */
- @Override
- public RedisClusterConnection getClusterConnection() {
- throw new UnsupportedOperationException("Jredis does not support Redis Cluster.");
- }
-
- /**
- * Post process a newly retrieved connection. Useful for decorating or executing initialization commands on a new
- * connection. This implementation simply returns the connection.
- *
- * @param connection
- * @return processed connection
- */
- protected RedisConnection postProcessConnection(JredisConnection connection) {
- return connection;
- }
-
- public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
- if (ex instanceof ClientRuntimeException) {
- return JredisUtils.convertJredisAccessException((ClientRuntimeException) ex);
- }
- return null;
- }
-
- /**
- * Returns the Redis host name of this factory.
- *
- * @return Returns the hostName
- */
- public String getHostName() {
- return hostName;
- }
-
- /**
- * Sets the Redis host name for this factory.
- *
- * @param hostName The hostName to set.
- */
- public void setHostName(String hostName) {
- this.hostName = hostName;
- }
-
- /**
- * Returns the Redis port.
- *
- * @return Returns the port
- */
- public int getPort() {
- return port;
- }
-
- /**
- * Sets the Redis port.
- *
- * @param port The port to set.
- */
- public void setPort(int port) {
- this.port = port;
- }
-
- /**
- * Returns the password used for authenticating with the Redis server.
- *
- * @return password for authentication
- */
- public String getPassword() {
- return password;
- }
-
- /**
- * Sets the password used for authenticating with the Redis server.
- *
- * @param password the password to set
- */
- public void setPassword(String password) {
- this.password = password;
- }
-
- /**
- * Returns the index of the database.
- *
- * @return Returns the database index
- */
- public int getDatabase() {
- return dbIndex;
- }
-
- /**
- * Sets the index of the database used by this connection factory. Can be between 0 (default) and 15.
- *
- * @param index database index
- */
- public void setDatabase(int index) {
- Assert.isTrue(index >= 0, "invalid DB index (a positive index required)");
- this.dbIndex = index;
- }
-
- /**
- * {@link JredisConnection} does not support pipeline or transactions
- */
- public boolean getConvertPipelineAndTxResults() {
- return false;
- }
-
- @Override
- public RedisSentinelConnection getSentinelConnection() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/src/main/java/org/springframework/data/redis/connection/jredis/JredisPool.java b/src/main/java/org/springframework/data/redis/connection/jredis/JredisPool.java
deleted file mode 100644
index 7f7ddd1b8..000000000
--- a/src/main/java/org/springframework/data/redis/connection/jredis/JredisPool.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright 2011-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.data.redis.connection.jredis;
-
-import org.apache.commons.pool2.BasePooledObjectFactory;
-import org.apache.commons.pool2.PooledObject;
-import org.apache.commons.pool2.impl.DefaultPooledObject;
-import org.apache.commons.pool2.impl.GenericObjectPool;
-import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
-import org.jredis.JRedis;
-import org.jredis.connector.Connection;
-import org.jredis.connector.Connection.Socket.Property;
-import org.jredis.connector.ConnectionSpec;
-import org.jredis.ri.alphazero.JRedisClient;
-import org.jredis.ri.alphazero.connection.DefaultConnectionSpec;
-import org.springframework.data.redis.connection.Pool;
-import org.springframework.data.redis.connection.PoolException;
-import org.springframework.util.StringUtils;
-
-/**
- * JRedis implementation of {@link Pool}
- *
- * @author Jennifer Hickey
- * @author Christoph Strobl
- * @deprecated since 1.7. Will be removed in subsequent version.
- */
-@Deprecated
-public class JredisPool implements Pool {
-
- private final GenericObjectPool internalPool;
-
- /**
- * Uses the {@link Config} and {@link ConnectionSpec} defaults for configuring the connection pool
- *
- * @param hostName The Redis host
- * @param port The Redis port
- */
- public JredisPool(String hostName, int port) {
- this(hostName, port, 0, null, 0, new GenericObjectPoolConfig());
- }
-
- /**
- * Uses the {@link ConnectionSpec} defaults for configuring the connection pool
- *
- * @param hostName The Redis host
- * @param port The Redis port
- * @param poolConfig The pool {@link Config}
- */
- public JredisPool(String hostName, int port, GenericObjectPoolConfig poolConfig) {
- this(hostName, port, 0, null, 0, poolConfig);
- }
-
- /**
- * Uses the {@link Config} defaults for configuring the connection pool
- *
- * @param connectionSpec The {@link ConnectionSpec} for connecting to Redis
- */
- public JredisPool(ConnectionSpec connectionSpec) {
- this.internalPool = new GenericObjectPool(new JredisFactory(connectionSpec), new GenericObjectPoolConfig());
- }
-
- /**
- * @param connectionSpec The {@link ConnectionSpec} for connecting to Redis
- * @param poolConfig The pool {@link Config}
- */
- public JredisPool(ConnectionSpec connectionSpec, GenericObjectPoolConfig poolConfig) {
- this.internalPool = new GenericObjectPool(new JredisFactory(connectionSpec), poolConfig);
- }
-
- /**
- * Uses the {@link Config} defaults for configuring the connection pool
- *
- * @param hostName The Redis host
- * @param port The Redis port
- * @param dbIndex The index of the database all connections should use. The database will only be selected on initial
- * creation of the pooled {@link JRedis} instances. Since calling select directly on {@link JRedis} is not
- * supported, it is assumed that connections can be re-used without subsequent selects.
- * @param password The password used for authenticating with the Redis server or null if no password required
- * @param timeout The socket timeout or 0 to use the default socket timeout
- */
- public JredisPool(String hostName, int port, int dbIndex, String password, int timeout) {
- this(hostName, port, dbIndex, password, timeout, new GenericObjectPoolConfig());
- }
-
- /**
- * @param hostName The Redis host
- * @param port The Redis port
- * @param dbIndex The index of the database all connections should use
- * @param password The password used for authenticating with the Redis server or null if no password required
- * @param timeout The socket timeout or 0 to use the default socket timeout
- * @param poolConfig The pool {@link Config}
- */
- public JredisPool(String hostName, int port, int dbIndex, String password, int timeout,
- GenericObjectPoolConfig poolConfig) {
- ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec(hostName, port, dbIndex, null);
- connectionSpec.setConnectionFlag(Connection.Flag.RELIABLE, false);
- if (StringUtils.hasLength(password)) {
- connectionSpec.setCredentials(password);
- }
- if (timeout > 0) {
- connectionSpec.setSocketProperty(Property.SO_TIMEOUT, timeout);
- }
- this.internalPool = new GenericObjectPool(new JredisFactory(connectionSpec), poolConfig);
- }
-
- public JRedis getResource() {
- try {
- return internalPool.borrowObject();
- } catch (Exception e) {
- throw new PoolException("Could not get a resource from the pool", e);
- }
- }
-
- public void returnBrokenResource(final JRedis resource) {
- try {
- internalPool.invalidateObject(resource);
- } catch (Exception e) {
- throw new PoolException("Could not invalidate the broken resource", e);
- }
- }
-
- public void returnResource(final JRedis resource) {
- try {
- internalPool.returnObject(resource);
- } catch (Exception e) {
- throw new PoolException("Could not return the resource to the pool", e);
- }
- }
-
- public void destroy() {
- try {
- internalPool.close();
- } catch (Exception e) {
- throw new PoolException("Could not destroy the pool", e);
- }
- }
-
- private static class JredisFactory extends BasePooledObjectFactory {
-
- private final ConnectionSpec connectionSpec;
-
- public JredisFactory(ConnectionSpec connectionSpec) {
- super();
- this.connectionSpec = connectionSpec;
- }
-
- @Override
- public void destroyObject(final PooledObject obj) throws Exception {
- try {
- obj.getObject().quit();
- } catch (Exception e) {
- // Errors may happen if returning a broken resource
- }
- }
-
- @Override
- public boolean validateObject(final PooledObject obj) {
- try {
- obj.getObject().ping();
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
- @Override
- public JRedis create() throws Exception {
- return new JRedisClient(connectionSpec);
- }
-
- @Override
- public PooledObject wrap(JRedis obj) {
- return new DefaultPooledObject(obj);
- }
- }
-
-}
diff --git a/src/main/java/org/springframework/data/redis/connection/jredis/JredisUtils.java b/src/main/java/org/springframework/data/redis/connection/jredis/JredisUtils.java
deleted file mode 100644
index 28e82df99..000000000
--- a/src/main/java/org/springframework/data/redis/connection/jredis/JredisUtils.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2011-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.data.redis.connection.jredis;
-
-import java.util.Map;
-import java.util.Properties;
-
-import org.jredis.ClientRuntimeException;
-import org.jredis.RedisException;
-import org.jredis.RedisType;
-import org.jredis.Sort;
-import org.jredis.connector.NotConnectedException;
-import org.springframework.dao.DataAccessException;
-import org.springframework.dao.InvalidDataAccessApiUsageException;
-import org.springframework.dao.InvalidDataAccessResourceUsageException;
-import org.springframework.data.redis.RedisConnectionFailureException;
-import org.springframework.data.redis.connection.DataType;
-import org.springframework.data.redis.connection.SortParameters;
-import org.springframework.data.redis.connection.SortParameters.Order;
-import org.springframework.data.redis.connection.SortParameters.Range;
-
-/**
- * Helper class featuring methods for JRedis connection handling, providing support for exception translation.
- *
- * @author Costin Leau
- * @author Jennifer Hickey
- * @deprecated since 1.7. Will be removed in subsequent version.
- */
-@Deprecated
-public abstract class JredisUtils {
-
- /**
- * Converts the given, native JRedis exception to Spring's DAO hierarchy.
- *
- * @param ex JRedis exception
- * @return converted exception
- */
- public static DataAccessException convertJredisAccessException(RedisException ex) {
- return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
- }
-
- /**
- * Converts the given, native JRedis exception to Spring's DAO hierarchy.
- *
- * @param ex JRedis exception
- * @return converted exception
- */
- public static DataAccessException convertJredisAccessException(ClientRuntimeException ex) {
- if (ex instanceof NotConnectedException) {
- return new RedisConnectionFailureException(ex.getMessage(), ex);
- }
- return new InvalidDataAccessResourceUsageException(ex.getMessage(), ex);
- }
-
- static DataType convertDataType(RedisType type) {
- switch (type) {
- case NONE:
- return DataType.NONE;
- case string:
- return DataType.STRING;
- case list:
- return DataType.LIST;
- case set:
- return DataType.SET;
- // case zset:
- // return DataType.ZSET;
- case hash:
- return DataType.HASH;
- }
-
- return null;
- }
-
- static Sort applySortingParams(Sort jredisSort, SortParameters params, byte[] storeKey) {
- if (params != null) {
- byte[] byPattern = params.getByPattern();
- if (byPattern != null) {
- jredisSort.BY(byPattern);
- }
- byte[][] getPattern = params.getGetPattern();
-
- if (getPattern != null && getPattern.length > 0) {
- for (byte[] bs : getPattern) {
- jredisSort.GET(bs);
- }
- }
- Range limit = params.getLimit();
- if (limit != null) {
- jredisSort.LIMIT(limit.getStart(), limit.getCount());
- }
- Order order = params.getOrder();
- if (order != null && order.equals(Order.DESC)) {
- jredisSort.DESC();
- }
- Boolean isAlpha = params.isAlphabetic();
- if (isAlpha != null && isAlpha) {
- jredisSort.ALPHA();
- }
- }
-
- if (storeKey != null) {
- jredisSort.STORE(storeKey);
- }
-
- return jredisSort;
- }
-
- static Properties info(Map map) {
- Properties info = new Properties();
- info.putAll(map);
- return info;
- }
-
- static Long toLong(Boolean source) {
- return source ? 1l : 0l;
- }
-}
diff --git a/src/main/java/org/springframework/data/redis/connection/jredis/package-info.java b/src/main/java/org/springframework/data/redis/connection/jredis/package-info.java
deleted file mode 100644
index a52db9646..000000000
--- a/src/main/java/org/springframework/data/redis/connection/jredis/package-info.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * Connection package for JRedis library.
- * @deprecated since 1.7. Will be removed in subsequent version.
- */
-package org.springframework.data.redis.connection.jredis;
-
diff --git a/src/main/java/org/springframework/data/redis/connection/srp/SrpConnection.java b/src/main/java/org/springframework/data/redis/connection/srp/SrpConnection.java
deleted file mode 100644
index 960b1d3fd..000000000
--- a/src/main/java/org/springframework/data/redis/connection/srp/SrpConnection.java
+++ /dev/null
@@ -1,2844 +0,0 @@
-/*
- * Copyright 2011-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.data.redis.connection.srp;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.Queue;
-import java.util.Set;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import org.springframework.core.convert.converter.Converter;
-import org.springframework.dao.DataAccessException;
-import org.springframework.data.geo.Circle;
-import org.springframework.data.geo.Distance;
-import org.springframework.data.geo.GeoResults;
-import org.springframework.data.geo.Metric;
-import org.springframework.data.geo.Point;
-import org.springframework.data.redis.ExceptionTranslationStrategy;
-import org.springframework.data.redis.FallbackExceptionTranslationStrategy;
-import org.springframework.data.redis.RedisConnectionFailureException;
-import org.springframework.data.redis.connection.AbstractRedisConnection;
-import org.springframework.data.redis.connection.DataType;
-import org.springframework.data.redis.connection.FutureResult;
-import org.springframework.data.redis.connection.MessageListener;
-import org.springframework.data.redis.connection.RedisNode;
-import org.springframework.data.redis.connection.RedisPipelineException;
-import org.springframework.data.redis.connection.RedisSubscribedConnectionException;
-import org.springframework.data.redis.connection.ReturnType;
-import org.springframework.data.redis.connection.SortParameters;
-import org.springframework.data.redis.connection.Subscription;
-import org.springframework.data.redis.connection.convert.Converters;
-import org.springframework.data.redis.core.Cursor;
-import org.springframework.data.redis.core.ScanOptions;
-import org.springframework.data.redis.core.types.Expiration;
-import org.springframework.data.redis.core.types.RedisClientInfo;
-import org.springframework.util.Assert;
-
-import com.google.common.base.Charsets;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-
-import redis.Command;
-import redis.client.RedisClient;
-import redis.client.RedisClient.Pipeline;
-import redis.client.RedisException;
-import redis.reply.MultiBulkReply;
-import redis.reply.Reply;
-
-/**
- * {@code RedisConnection} implementation on top of spullara Redis
- * Protocol library.
- *
- * @author Costin Leau
- * @author Jennifer Hickey
- * @author Christoph Strobl
- * @author Thomas Darimont
- * @author David Liu
- * @author Ninad Divadkar
- * @author Mark Paluch
- * @deprecated since 1.7. Will be removed in subsequent version.
- */
-@Deprecated
-public class SrpConnection extends AbstractRedisConnection {
-
- private static final ExceptionTranslationStrategy EXCEPTION_TRANSLATION = new FallbackExceptionTranslationStrategy(
- SrpConverters.exceptionConverter());
-
- private static final Object[] EMPTY_PARAMS_ARRAY = new Object[0];
- private static final byte[] WITHSCORES = "WITHSCORES".getBytes(Charsets.UTF_8);
- private static final byte[] BY = "BY".getBytes(Charsets.UTF_8);
- private static final byte[] GET = "GET".getBytes(Charsets.UTF_8);
- private static final byte[] ALPHA = "ALPHA".getBytes(Charsets.UTF_8);
- private static final byte[] STORE = "STORE".getBytes(Charsets.UTF_8);
-
- private final RedisClient client;
- private final BlockingQueue queue;
-
- private boolean isClosed = false;
- private boolean isMulti = false;
- private boolean pipelineRequested = false;
- private Pipeline pipeline;
- private PipelineTracker callback;
- private PipelineTracker txTracker;
- private volatile SrpSubscription subscription;
- private boolean convertPipelineAndTxResults = true;
-
- @SuppressWarnings("rawtypes")
- private class PipelineTracker implements FutureCallback {
-
- private final List results = Collections.synchronizedList(new ArrayList());
- private final Queue futureResults = new LinkedList();
- private boolean convertResults;
-
- public PipelineTracker(boolean convertResults) {
- this.convertResults = convertResults;
- }
-
- public void onSuccess(Reply result) {
- results.add(result.data());
- }
-
- public void onFailure(Throwable t) {
- results.add(t);
- }
-
- @SuppressWarnings("unchecked")
- public List complete() {
- int txResults = 0;
- List> futures = new ArrayList>();
- for (FutureResult future : futureResults) {
- if (future instanceof SrpTxResult) {
- txResults++;
- } else {
- ListenableFuture extends Reply> f = (ListenableFuture extends Reply>) future.getResultHolder();
- futures.add(f);
- }
- }
- try {
- Futures.successfulAsList(futures).get();
- } catch (Exception ex) {
- // ignore
- }
- if (futureResults.size() != results.size() + txResults) {
- throw new RedisPipelineException(
- "Received a different number of results than expected. Expected: " + futureResults.size(), results);
- }
- List convertedResults = new ArrayList();
-
- int i = 0;
- for (FutureResult future : futureResults) {
- if (future instanceof SrpTxResult) {
- PipelineTracker txTracker = ((SrpTxResult) future).getResultHolder();
- if (txTracker != null) {
- convertedResults.add(getPipelinedResults(txTracker, true));
- } else {
- convertedResults.add(null);
- }
- } else {
- Object result = results.get(i);
- if (result instanceof Exception || !convertResults) {
- convertedResults.add(result);
- } else if (!(future.isStatus())) {
- convertedResults.add(future.convert(result));
- }
- i++;
- }
- }
- return convertedResults;
- }
-
- public void addCommand(FutureResult result) {
- futureResults.add(result);
- if (!(result instanceof SrpTxResult) && result.getResultHolder() != null) {
- Futures.addCallback(((SrpGenericResult) result).getResultHolder(), this);
- }
- }
-
- public void close() {
- results.clear();
- futureResults.clear();
- }
- }
-
- @SuppressWarnings("rawtypes")
- private class SrpGenericResult extends FutureResult> {
- public SrpGenericResult(ListenableFuture extends Reply> resultHolder, Converter converter) {
- super(resultHolder, converter);
- }
-
- public SrpGenericResult(ListenableFuture extends Reply> resultHolder) {
- super(resultHolder);
- }
-
- @Override
- public Object get() {
- throw new UnsupportedOperationException();
- }
- }
-
- @SuppressWarnings("rawtypes")
- private class SrpResult extends SrpGenericResult {
- public SrpResult(ListenableFuture extends Reply> resultHolder, Converter converter) {
- super(resultHolder, converter);
- }
-
- public SrpResult(ListenableFuture extends Reply> resultHolder) {
- super(resultHolder);
- }
- }
-
- private class SrpStatusResult extends SrpResult {
- @SuppressWarnings("rawtypes")
- public SrpStatusResult(ListenableFuture extends Reply> resultHolder) {
- super(resultHolder);
- setStatus(true);
- }
- }
-
- private class SrpTxResult extends FutureResult {
- public SrpTxResult(PipelineTracker txTracker) {
- super(txTracker);
- }
-
- public List get() {
- if (resultHolder == null) {
- return null;
- }
- return resultHolder.complete();
- }
- }
-
- SrpConnection(RedisClient client) {
-
- Assert.notNull(client);
- this.client = client;
- this.queue = new ArrayBlockingQueue(50);
- }
-
- public SrpConnection(String host, int port, BlockingQueue queue) {
- try {
- this.client = new RedisClient(host, port);
- this.queue = queue;
- } catch (IOException e) {
- throw new RedisConnectionFailureException("Could not connect", e);
- } catch (RedisException e) {
- throw new RedisConnectionFailureException("Could not connect", e);
- }
- }
-
- public SrpConnection(String host, int port, String password, BlockingQueue queue) {
- this(host, port, queue);
- try {
- this.client.auth(password);
- } catch (RedisException e) {
- throw new RedisConnectionFailureException("Could not connect", e);
- }
- }
-
- protected DataAccessException convertSrpAccessException(Exception ex) {
- return EXCEPTION_TRANSLATION.translate(ex);
- }
-
- public Object execute(String command, byte[]... args) {
- Assert.hasText(command, "a valid command needs to be specified");
- try {
- String name = command.trim().toUpperCase();
- Command cmd = new Command(name.getBytes(Charsets.UTF_8), args);
- if (isPipelined()) {
- pipeline(new SrpResult(client.pipeline(name, cmd)));
- return null;
- }
- return client.execute(name, cmd).data();
- } catch (RedisException ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void close() throws DataAccessException {
-
- super.close();
- isClosed = true;
- queue.remove(this);
-
- if (subscription != null) {
- if (subscription.isAlive()) {
- subscription.doClose();
- }
- subscription = null;
- }
-
- try {
- client.close();
- } catch (IOException ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public boolean isClosed() {
- return isClosed;
- }
-
- public RedisClient getNativeConnection() {
- return client;
- }
-
- public boolean isQueueing() {
- return isMulti;
- }
-
- public boolean isPipelined() {
- return pipelineRequested || (txTracker != null);
- }
-
- public void openPipeline() {
- pipelineRequested = true;
- initPipeline();
- }
-
- public List sort(byte[] key, SortParameters params) {
-
- Object[] sort = sortParams(params);
-
- try {
- if (isPipelined()) {
- pipeline(new SrpGenericResult(pipeline.sort(key, sort), SrpConverters.repliesToBytesList()));
- return null;
- }
- return SrpConverters.toBytesList((Reply[]) client.sort(key, sort).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long sort(byte[] key, SortParameters params, byte[] sortKey) {
-
- Object[] sort = sortParams(params, sortKey);
-
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.sort(key, sort)));
- return null;
- }
- return ((Long) client.sort(key, sort).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long dbSize() {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.dbsize()));
- return null;
- }
- return client.dbsize().data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void flushDb() {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.flushdb()));
- return;
- }
- client.flushdb();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void flushAll() {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.flushall()));
- return;
- }
- client.flushall();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void bgSave() {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.bgsave()));
- return;
- }
- client.bgsave();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void bgReWriteAof() {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.bgrewriteaof()));
- return;
- }
- client.bgrewriteaof();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- /**
- * @deprecated As of 1.3, use {@link #bgReWriteAof}.
- */
- @Deprecated
- public void bgWriteAof() {
- bgReWriteAof();
- }
-
- public void save() {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.save()));
- return;
- }
- client.save();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public List getConfig(String param) {
- try {
- if (isPipelined()) {
- pipeline(new SrpGenericResult(pipeline.config_get(param), SrpConverters.repliesToStringList()));
- return null;
- }
- return SrpConverters.toStringList(client.config_get(param).data().toString());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Properties info() {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.info(null), SrpConverters.bytesToProperties()));
- return null;
- }
- return SrpConverters.toProperties(client.info(null).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Properties info(String section) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.info(section), SrpConverters.bytesToProperties()));
- return null;
- }
- return SrpConverters.toProperties(client.info(section).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long lastSave() {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.lastsave()));
- return null;
- }
- return client.lastsave().data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void setConfig(String param, String value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.config_set(param, value)));
- return;
- }
- client.config_set(param, value);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void resetConfigStats() {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.config_resetstat()));
- return;
- }
- client.config_resetstat();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void shutdown() {
- byte[] save = "SAVE".getBytes(Charsets.UTF_8);
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.shutdown(save, null)));
- return;
- }
- client.shutdown(save, null);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisServerCommands#shutdown(org.springframework.data.redis.connection.RedisServerCommands.ShutdownOption)
- */
- @Override
- public void shutdown(ShutdownOption option) {
-
- if (option == null) {
- shutdown();
- return;
- }
-
- byte[] save = option.name().getBytes(Charsets.UTF_8);
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.shutdown(save, null)));
- return;
- }
- client.shutdown(save, null);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
-
- }
-
- public byte[] echo(byte[] message) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.echo(message)));
- return null;
- }
- return client.echo(message).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public String ping() {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.ping()));
- return null;
- }
- return client.ping().data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long del(byte[]... keys) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.del((Object[]) keys)));
- return null;
- }
- return client.del((Object[]) keys).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void discard() {
- isMulti = false;
- try {
- // discard tracked futures
- txTracker = null;
- client.discard();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public List exec() {
- isMulti = false;
- try {
- Future exec = client.exec();
- // Need to wait on execution or subsequent non-pipelined calls may read exec results
- boolean resultsSet = exec.get();
- if (!resultsSet) {
- // This is the case where a nil MultiBulk Reply was returned b/c watched variable modified
- if (pipelineRequested) {
- pipeline(new SrpTxResult(null));
- }
- return null;
- }
- if (pipelineRequested) {
- pipeline(new SrpTxResult(txTracker));
- return null;
- }
- return closeTransaction();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- } finally {
- txTracker = null;
- }
- }
-
- public Boolean exists(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.exists(key), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.exists(key).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean expire(byte[] key, long seconds) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.expire(key, seconds), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.expire(key, seconds).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean expireAt(byte[] key, long unixTime) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.expireat(key, unixTime), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.expireat(key, unixTime).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean pExpire(byte[] key, long millis) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.pexpire(key, millis), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.pexpire(key, millis).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean pExpireAt(byte[] key, long unixTimeInMillis) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.pexpireat(key, unixTimeInMillis), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.pexpireat(key, unixTimeInMillis).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Set keys(byte[] pattern) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.keys(pattern), SrpConverters.repliesToBytesSet()));
- return null;
- }
- return SrpConverters.toBytesSet(client.keys(pattern).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void multi() {
- if (isQueueing()) {
- return;
- }
- isMulti = true;
- initTxTracker();
- try {
- client.multi();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean persist(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.persist(key), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.persist(key).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean move(byte[] key, int dbIndex) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.move(key, dbIndex), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.move(key, dbIndex).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public byte[] randomKey() {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.randomkey()));
- return null;
- }
- return client.randomkey().data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void rename(byte[] oldName, byte[] newName) {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.rename(oldName, newName)));
- return;
- }
- client.rename(oldName, newName);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean renameNX(byte[] oldName, byte[] newName) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.renamenx(oldName, newName), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.renamenx(oldName, newName).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void select(int dbIndex) {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.select(dbIndex)));
- return;
- }
- client.select(dbIndex);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisKeyCommands#ttl(byte[])
- */
- @Override
- public Long ttl(byte[] key) {
-
- Assert.notNull(key, "Key must not be null!");
-
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.ttl(key)));
- return null;
- }
-
- return client.ttl(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisKeyCommands#ttl(byte[], java.util.concurrent.TimeUnit)
- */
- @Override
- public Long ttl(byte[] key, TimeUnit timeUnit) {
-
- Assert.notNull(key, "Key must not be null!");
-
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.ttl(key), Converters.secondsToTimeUnit(timeUnit)));
- return null;
- }
- return Converters.secondsToTimeUnit(client.ttl(key).data(), timeUnit);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisKeyCommands#pTtl(byte[])
- */
- @Override
- public Long pTtl(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.pttl(key)));
- return null;
- }
- return client.pttl(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisKeyCommands#pTtl(byte[], java.util.concurrent.TimeUnit)
- */
- @Override
- public Long pTtl(byte[] key, TimeUnit timeUnit) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.pttl(key), Converters.millisecondsToTimeUnit(timeUnit)));
- return null;
- }
- return Converters.millisecondsToTimeUnit(client.pttl(key).data(), timeUnit);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public byte[] dump(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.dump(key)));
- return null;
- }
- return client.dump(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void restore(byte[] key, long ttlInMillis, byte[] serializedValue) {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.restore(key, ttlInMillis, serializedValue)));
- return;
- }
- client.restore(key, ttlInMillis, serializedValue);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public DataType type(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.type(key), SrpConverters.stringToDataType()));
- return null;
- }
- return SrpConverters.toDataType(client.type(key).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void unwatch() {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.unwatch()));
- return;
- }
- client.unwatch();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void watch(byte[]... keys) {
- if (isQueueing()) {
- throw new UnsupportedOperationException();
- }
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.watch((Object[]) keys)));
- return;
- } else {
- client.watch((Object[]) keys);
- }
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- //
- // String commands
- //
-
- public byte[] get(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.get(key)));
- return null;
- }
-
- return client.get(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void set(byte[] key, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.set(key, value)));
- return;
- }
- client.set(key, value);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisStringCommands#set(byte[], byte[], org.springframework.data.redis.core.types.Expiration, org.springframework.data.redis.connection.RedisStringCommands.SetOption)
- */
- @Override
- public void set(byte[] key, byte[] value, Expiration expiration, SetOption option) {
- throw new UnsupportedOperationException(
- "SET with options is not supported for Srp. Please use SETNX, SETEX, PSETEX.");
- }
-
- public byte[] getSet(byte[] key, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.getset(key, value)));
- return null;
- }
- return client.getset(key, value).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long append(byte[] key, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.append(key, value)));
- return null;
- }
- return client.append(key, value).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public List mGet(byte[]... keys) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.mget((Object[]) keys), SrpConverters.repliesToBytesList()));
- return null;
- }
- return SrpConverters.toBytesList(client.mget((Object[]) keys).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void mSet(Map tuples) {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.mset((Object[]) SrpConverters.toByteArrays(tuples))));
- return;
- }
- client.mset((Object[]) SrpConverters.toByteArrays(tuples));
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean mSetNX(Map tuples) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.msetnx((Object[]) SrpConverters.toByteArrays(tuples)),
- SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.msetnx((Object[]) SrpConverters.toByteArrays(tuples)).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void setEx(byte[] key, long time, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.setex(key, time, value)));
- return;
- }
- client.setex(key, time, value);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisStringCommands#pSetEx(byte[], long, byte[])
- */
- @Override
- public void pSetEx(byte[] key, long milliseconds, byte[] value) {
-
- try {
- if (isPipelined()) {
- doPipelined(pipeline.psetex(key, milliseconds, value));
- return;
- }
- client.psetex(key, milliseconds, value);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean setNX(byte[] key, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.setnx(key, value), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.setnx(key, value).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public byte[] getRange(byte[] key, long start, long end) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.getrange(key, start, end)));
- return null;
- }
- return client.getrange(key, start, end).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long decr(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.decr(key)));
- return null;
- }
- return client.decr(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long decrBy(byte[] key, long value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.decrby(key, value)));
- return null;
- }
- return client.decrby(key, value).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long incr(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.incr(key)));
- return null;
- }
- return client.incr(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long incrBy(byte[] key, long value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.incrby(key, value)));
- return null;
- }
- return client.incrby(key, value).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Double incrBy(byte[] key, double value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.incrbyfloat(key, value), SrpConverters.bytesToDouble()));
- return null;
- }
- return SrpConverters.toDouble(client.incrbyfloat(key, value).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean getBit(byte[] key, long offset) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.getbit(key, offset), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.getbit(key, offset).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean setBit(byte[] key, long offset, boolean value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpGenericResult(pipeline.setbit(key, offset, SrpConverters.toBit(value)),
- SrpConverters.longToBooleanConverter()));
- return null;
- }
- return SrpConverters.toBoolean(client.setbit(key, offset, SrpConverters.toBit(value)));
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void setRange(byte[] key, byte[] value, long start) {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.setrange(key, start, value)));
- return;
- }
- client.setrange(key, start, value);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long strLen(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.strlen(key)));
- return null;
- }
- return client.strlen(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long bitCount(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.bitcount(key, 0, -1)));
- return null;
- }
- return client.bitcount(key, 0, -1).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long bitCount(byte[] key, long begin, long end) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.bitcount(key, begin, end)));
- return null;
- }
- return client.bitcount(key, begin, end).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long bitOp(BitOperation op, byte[] destination, byte[]... keys) {
- if (op == BitOperation.NOT && keys.length > 1) {
- throw new UnsupportedOperationException("Bitop NOT should only be performed against one key");
- }
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.bitop(SrpConverters.toBytes(op), destination, (Object[]) keys)));
- return null;
- }
- return client.bitop(SrpConverters.toBytes(op), destination, (Object[]) keys).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- //
- // List commands
- //
-
- public Long lPush(byte[] key, byte[]... values) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.lpush(key, (Object[]) values)));
- return null;
- }
- return client.lpush(key, (Object[]) values).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long rPush(byte[] key, byte[]... values) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.rpush(key, (Object[]) values)));
- return null;
- }
- return client.rpush(key, (Object[]) values).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public List bLPop(int timeout, byte[]... keys) {
- Object[] args = popArgs(timeout, keys);
-
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.blpop(args), SrpConverters.repliesToBytesList()));
- return null;
- }
- return SrpConverters.toBytesList(client.blpop(args).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public List bRPop(int timeout, byte[]... keys) {
- Object[] args = popArgs(timeout, keys);
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.brpop(args), SrpConverters.repliesToBytesList()));
- return null;
- }
- return SrpConverters.toBytesList(client.brpop(args).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public byte[] lIndex(byte[] key, long index) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.lindex(key, index)));
- return null;
- }
- return client.lindex(key, index).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long lInsert(byte[] key, Position where, byte[] pivot, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.linsert(key, SrpConverters.toBytes(where), pivot, value)));
- return null;
- }
- return client.linsert(key, SrpConverters.toBytes(where), pivot, value).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long lLen(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.llen(key)));
- return null;
- }
- return client.llen(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public byte[] lPop(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.lpop(key)));
- return null;
- }
- return client.lpop(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public List lRange(byte[] key, long start, long end) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.lrange(key, start, end), SrpConverters.repliesToBytesList()));
- return null;
- }
- return SrpConverters.toBytesList(client.lrange(key, start, end).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long lRem(byte[] key, long count, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.lrem(key, count, value)));
- return null;
- }
- return client.lrem(key, count, value).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void lSet(byte[] key, long index, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.lset(key, index, value)));
- return;
- }
- client.lset(key, index, value);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void lTrim(byte[] key, long start, long end) {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.ltrim(key, start, end)));
- return;
- }
- client.ltrim(key, start, end);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public byte[] rPop(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.rpop(key)));
- return null;
- }
- return client.rpop(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public byte[] rPopLPush(byte[] srcKey, byte[] dstKey) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.rpoplpush(srcKey, dstKey)));
- return null;
- }
- return client.rpoplpush(srcKey, dstKey).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.brpoplpush(srcKey, dstKey, timeout)));
- return null;
- }
- return (byte[]) client.brpoplpush(srcKey, dstKey, timeout).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long lPushX(byte[] key, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.lpushx(key, value)));
- return null;
- }
- return client.lpushx(key, value).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long rPushX(byte[] key, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.rpushx(key, value)));
- return null;
- }
- return client.rpushx(key, value).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- //
- // Set commands
- //
-
- public Long sAdd(byte[] key, byte[]... values) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.sadd(key, (Object[]) values)));
- return null;
- }
- return client.sadd(key, (Object[]) values).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long sCard(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.scard(key)));
- return null;
- }
- return client.scard(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Set sDiff(byte[]... keys) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.sdiff((Object[]) keys), SrpConverters.repliesToBytesSet()));
- return null;
- }
- return SrpConverters.toBytesSet(client.sdiff((Object[]) keys).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long sDiffStore(byte[] destKey, byte[]... keys) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.sdiffstore(destKey, (Object[]) keys)));
- return null;
- }
- return client.sdiffstore(destKey, (Object[]) keys).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Set sInter(byte[]... keys) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.sinter((Object[]) keys), SrpConverters.repliesToBytesSet()));
- return null;
- }
- return SrpConverters.toBytesSet(client.sinter((Object[]) keys).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long sInterStore(byte[] destKey, byte[]... keys) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.sinterstore(destKey, (Object[]) keys)));
- return null;
- }
- return client.sinterstore(destKey, (Object[]) keys).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean sIsMember(byte[] key, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.sismember(key, value), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.sismember(key, value).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Set sMembers(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.smembers(key), SrpConverters.repliesToBytesSet()));
- return null;
- }
- return SrpConverters.toBytesSet(client.smembers(key).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean sMove(byte[] srcKey, byte[] destKey, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.smove(srcKey, destKey, value), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.smove(srcKey, destKey, value).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public byte[] sPop(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.spop(key)));
- return null;
- }
- return client.spop(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public byte[] sRandMember(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.srandmember(key, null)));
- return null;
- }
- return (byte[]) client.srandmember(key, null).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public List sRandMember(byte[] key, long count) {
- try {
- if (isPipelined()) {
- pipeline(new SrpGenericResult(pipeline.srandmember(key, count), SrpConverters.repliesToBytesList()));
- return null;
- }
- return SrpConverters.toBytesList(((MultiBulkReply) client.srandmember(key, count)).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long sRem(byte[] key, byte[]... values) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.srem(key, (Object[]) values)));
- return null;
- }
- return client.srem(key, (Object[]) values).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Set sUnion(byte[]... keys) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.sunion((Object[]) keys), SrpConverters.repliesToBytesSet()));
- return null;
- }
- return SrpConverters.toBytesSet(client.sunion((Object[]) keys).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long sUnionStore(byte[] destKey, byte[]... keys) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.sunionstore(destKey, (Object[]) keys)));
- return null;
- }
- return client.sunionstore(destKey, (Object[]) keys).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- //
- // ZSet commands
- //
-
- public Boolean zAdd(byte[] key, double score, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zadd(new Object[] { key, score, value }), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.zadd(new Object[] { key, score, value }).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long zAdd(byte[] key, Set tuples) {
- try {
- List args = new ArrayList();
- args.add(key);
- args.addAll(SrpConverters.toObjects(tuples));
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zadd(args.toArray())));
- return null;
- }
- return client.zadd(args.toArray()).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long zCard(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zcard(key)));
- return null;
- }
- return client.zcard(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long zCount(byte[] key, double min, double max) {
- return zCount(key, new Range().gte(min).lte(max));
- }
-
- @Override
- public Long zCount(byte[] key, Range range) {
-
- byte[] min = SrpConverters.boundaryToBytesForZRange(range.getMin(), SrpConverters.toBytes("-inf"));
- byte[] max = SrpConverters.boundaryToBytesForZRange(range.getMax(), SrpConverters.toBytes("+inf"));
-
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zcount(key, min, max)));
- return null;
- }
- return client.zcount(key, min, max).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Double zIncrBy(byte[] key, double increment, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zincrby(key, increment, value), SrpConverters.bytesToDouble()));
- return null;
- }
- return SrpConverters.toDouble(client.zincrby(key, increment, value).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long zInterStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
- throw new UnsupportedOperationException();
- }
-
- public Long zInterStore(byte[] destKey, byte[]... sets) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zinterstore(destKey, sets.length, (Object[]) sets)));
- return null;
- }
- return client.zinterstore(destKey, sets.length, (Object[]) sets).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Set zRange(byte[] key, long start, long end) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zrange(key, start, end, null), SrpConverters.repliesToBytesSet()));
- return null;
- }
- return SrpConverters.toBytesSet(client.zrange(key, start, end, null).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Set zRangeWithScores(byte[] key, long start, long end) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zrange(key, start, end, WITHSCORES), SrpConverters.repliesToTupleSet()));
- return null;
- }
- return SrpConverters.toTupleSet(client.zrange(key, start, end, WITHSCORES).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Set zRangeByScore(byte[] key, double min, double max) {
- return zRangeByScore(key, new Range().gte(min).lte(max));
- }
-
- @Override
- public Set zRangeByScore(byte[] key, Range range) {
- return zRangeByScore(key, range, null);
- }
-
- @Override
- public Set zRangeByScore(byte[] key, Range range, Limit limit) {
-
- Assert.notNull(range, "Range for ZRANGEBYSCORE must not be null!");
-
- byte[] min = SrpConverters.boundaryToBytesForZRange(range.getMin(), SrpConverters.toBytes("-inf"));
- byte[] max = SrpConverters.boundaryToBytesForZRange(range.getMax(), SrpConverters.toBytes("+inf"));
-
- Object[] params = limit != null ? limitParams(limit.getOffset(), limit.getCount()) : EMPTY_PARAMS_ARRAY;
-
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zrangebyscore(key, min, max, null, params), SrpConverters.repliesToBytesSet()));
- return null;
- }
- return SrpConverters.toBytesSet(client.zrangebyscore(key, min, max, null, params).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Set zRangeByScoreWithScores(byte[] key, double min, double max) {
- return zRangeByScoreWithScores(key, new Range().gte(min).lte(max));
- }
-
- @Override
- public Set zRangeByScoreWithScores(byte[] key, Range range) {
- return zRangeByScoreWithScores(key, range, null);
- }
-
- @Override
- public Set zRangeByScoreWithScores(byte[] key, Range range, Limit limit) {
-
- Assert.notNull(range, "Range for ZRANGEBYSCOREWITHSCORES must not be null!");
-
- byte[] min = SrpConverters.boundaryToBytesForZRange(range.getMin(), SrpConverters.toBytes("-inf"));
- byte[] max = SrpConverters.boundaryToBytesForZRange(range.getMax(), SrpConverters.toBytes("+inf"));
-
- Object[] params = limit != null ? limitParams(limit.getOffset(), limit.getCount()) : EMPTY_PARAMS_ARRAY;
-
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zrangebyscore(key, min, max, WITHSCORES, params),
- SrpConverters.repliesToTupleSet()));
- return null;
- }
- return SrpConverters.toTupleSet(client.zrangebyscore(key, min, max, WITHSCORES, params).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Set zRevRangeWithScores(byte[] key, long start, long end) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zrevrange(key, start, end, WITHSCORES), SrpConverters.repliesToTupleSet()));
- return null;
- }
- return SrpConverters.toTupleSet(client.zrevrange(key, start, end, WITHSCORES).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- @Override
- public Set zRangeByScore(byte[] key, double min, double max, long offset, long count) {
-
- return zRangeByScore(key, new Range().gte(min).lte(max),
- new Limit().offset(Long.valueOf(offset).intValue()).count(Long.valueOf(count).intValue()));
- }
-
- @Override
- public Set zRangeByScoreWithScores(byte[] key, double min, double max, long offset, long count) {
-
- return zRangeByScoreWithScores(key, new Range().gte(min).lte(max),
- new Limit().offset(Long.valueOf(offset).intValue()).count(Long.valueOf(count).intValue()));
- }
-
- public Set zRevRangeByScore(byte[] key, double min, double max, long offset, long count) {
- return zRevRangeByScore(key, new Range().gte(min).lte(max),
- new Limit().offset(Long.valueOf(offset).intValue()).count(Long.valueOf(count).intValue()));
-
- }
-
- @Override
- public Set zRevRangeByScore(byte[] key, double min, double max) {
- return zRevRangeByScore(key, new Range().gte(min).lte(max));
- }
-
- @Override
- public Set zRevRangeByScoreWithScores(byte[] key, double min, double max, long offset, long count) {
- return zRevRangeByScoreWithScores(key, new Range().gte(min).lte(max),
- new Limit().offset(Long.valueOf(offset).intValue()).count(Long.valueOf(count).intValue()));
- }
-
- @Override
- public Set zRevRangeByScoreWithScores(byte[] key, double min, double max) {
- return zRevRangeByScoreWithScores(key, new Range().gte(min).lte(max));
- }
-
- @Override
- public Set zRevRangeByScore(byte[] key, Range range) {
- return zRevRangeByScore(key, range, null);
- }
-
- @Override
- public Set zRevRangeByScore(byte[] key, Range range, Limit limit) {
-
- Assert.notNull(range, "Range for ZRANGEBYSCOREWITHSCORES must not be null!");
-
- byte[] min = SrpConverters.boundaryToBytesForZRange(range.getMin(), SrpConverters.toBytes("-inf"));
- byte[] max = SrpConverters.boundaryToBytesForZRange(range.getMax(), SrpConverters.toBytes("+inf"));
-
- Object[] params = limit != null ? limitParams(limit.getOffset(), limit.getCount()) : EMPTY_PARAMS_ARRAY;
-
- try {
- if (isPipelined()) {
- pipeline(
- new SrpResult(pipeline.zrevrangebyscore(key, max, min, null, params), SrpConverters.repliesToBytesSet()));
- return null;
- }
- return SrpConverters.toBytesSet(client.zrevrangebyscore(key, max, min, null, params).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- @Override
- public Set zRevRangeByScoreWithScores(byte[] key, Range range) {
- return zRevRangeByScoreWithScores(key, range, null);
- }
-
- @Override
- public Set zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit) {
-
- Assert.notNull(range, "Range for ZRANGEBYSCOREWITHSCORES must not be null!");
-
- byte[] min = SrpConverters.boundaryToBytesForZRange(range.getMin(), SrpConverters.toBytes("-inf"));
- byte[] max = SrpConverters.boundaryToBytesForZRange(range.getMax(), SrpConverters.toBytes("+inf"));
-
- Object[] params = limit != null ? limitParams(limit.getOffset(), limit.getCount()) : EMPTY_PARAMS_ARRAY;
-
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zrevrangebyscore(key, max, min, WITHSCORES, params),
- SrpConverters.repliesToTupleSet()));
- return null;
- }
- return SrpConverters.toTupleSet(client.zrevrangebyscore(key, max, min, WITHSCORES, params).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long zRank(byte[] key, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zrank(key, value)));
- return null;
- }
- return (Long) client.zrank(key, value).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long zRem(byte[] key, byte[]... values) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zrem(key, (Object[]) values)));
- return null;
- }
- return client.zrem(key, (Object[]) values).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long zRemRange(byte[] key, long start, long end) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zremrangebyrank(key, start, end)));
- return null;
- }
- return client.zremrangebyrank(key, start, end).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long zRemRangeByScore(byte[] key, double min, double max) {
- return zRemRangeByScore(key, new Range().gte(min).lte(max));
- }
-
- @Override
- public Long zRemRangeByScore(byte[] key, Range range) {
-
- byte[] min = SrpConverters.boundaryToBytesForZRange(range.getMin(), SrpConverters.toBytes("-inf"));
- byte[] max = SrpConverters.boundaryToBytesForZRange(range.getMax(), SrpConverters.toBytes("+inf"));
-
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zremrangebyscore(key, min, max)));
- return null;
- }
- return client.zremrangebyscore(key, min, max).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Set zRevRange(byte[] key, long start, long end) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zrevrange(key, start, end, null), SrpConverters.repliesToBytesSet()));
- return null;
- }
- return SrpConverters.toBytesSet(client.zrevrange(key, start, end, null).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long zRevRank(byte[] key, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zrevrank(key, value)));
- return null;
- }
- return (Long) client.zrevrank(key, value).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Double zScore(byte[] key, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zscore(key, value), SrpConverters.bytesToDouble()));
- return null;
- }
- return SrpConverters.toDouble(client.zscore(key, value).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long zUnionStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
- throw new UnsupportedOperationException();
- }
-
- public Long zUnionStore(byte[] destKey, byte[]... sets) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zunionstore(destKey, sets.length, (Object[]) sets)));
- return null;
- }
- return client.zunionstore(destKey, sets.length, (Object[]) sets).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- //
- // Hash commands
- //
-
- public Boolean hSet(byte[] key, byte[] field, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.hset(key, field, value), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.hset(key, field, value).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean hSetNX(byte[] key, byte[] field, byte[] value) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.hsetnx(key, field, value), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.hsetnx(key, field, value).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long hDel(byte[] key, byte[]... fields) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.hdel(key, (Object[]) fields)));
- return null;
- }
- return client.hdel(key, (Object[]) fields).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Boolean hExists(byte[] key, byte[] field) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.hexists(key, field), SrpConverters.longToBoolean()));
- return null;
- }
- return SrpConverters.toBoolean(client.hexists(key, field).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public byte[] hGet(byte[] key, byte[] field) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.hget(key, field)));
- return null;
- }
- return client.hget(key, field).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Map hGetAll(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.hgetall(key), SrpConverters.repliesToBytesMap()));
- return null;
- }
- return SrpConverters.toBytesMap(client.hgetall(key).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long hIncrBy(byte[] key, byte[] field, long delta) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.hincrby(key, field, delta)));
- return null;
- }
- return client.hincrby(key, field, delta).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Double hIncrBy(byte[] key, byte[] field, double delta) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.hincrbyfloat(key, field, delta), SrpConverters.bytesToDouble()));
- return null;
- }
- return SrpConverters.toDouble(client.hincrbyfloat(key, field, delta).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Set hKeys(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.hkeys(key), SrpConverters.repliesToBytesSet()));
- return null;
- }
- return SrpConverters.toBytesSet(client.hkeys(key).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Long hLen(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.hlen(key)));
- return null;
- }
- return client.hlen(key).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public List hMGet(byte[] key, byte[]... fields) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.hmget(key, (Object[]) fields), SrpConverters.repliesToBytesList()));
- return null;
- }
- return SrpConverters.toBytesList(client.hmget(key, (Object[]) fields).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void hMSet(byte[] key, Map tuple) {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.hmset(key, (Object[]) SrpConverters.toByteArrays(tuple))));
- return;
- }
- client.hmset(key, (Object[]) SrpConverters.toByteArrays(tuple));
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public List hVals(byte[] key) {
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.hvals(key), SrpConverters.repliesToBytesList()));
- return null;
- }
- return SrpConverters.toBytesList(client.hvals(key).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- //
- // Scripting commands
- //
-
- public void scriptFlush() {
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.script_flush()));
- return;
- }
- client.script_flush();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void scriptKill() {
- if (isQueueing()) {
- throw new UnsupportedOperationException("Script kill not permitted in a transaction");
- }
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.script_kill()));
- return;
- }
- client.script_kill();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public String scriptLoad(byte[] script) {
- try {
- if (isPipelined()) {
- pipeline(new SrpGenericResult(pipeline.script_load(script), SrpConverters.bytesToString()));
- return null;
- }
- return SrpConverters.toString((byte[]) client.script_load(script).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public List scriptExists(String... scriptSha1) {
- try {
- if (isPipelined()) {
- pipeline(
- new SrpGenericResult(pipeline.script_exists((Object[]) scriptSha1), SrpConverters.repliesToBooleanList()));
- return null;
- }
- return SrpConverters.toBooleanList(((MultiBulkReply) client.script_exists_((Object[]) scriptSha1)).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- @SuppressWarnings("unchecked")
- public T eval(byte[] script, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
- try {
- if (isPipelined()) {
- pipeline(new SrpGenericResult(pipeline.eval(script, numKeys, (Object[]) keysAndArgs),
- new SrpScriptReturnConverter(returnType)));
- return null;
- }
- return (T) new SrpScriptReturnConverter(returnType)
- .convert(client.eval(script, numKeys, (Object[]) keysAndArgs).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- @SuppressWarnings("unchecked")
- public T evalSha(String scriptSha1, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
- try {
- if (isPipelined()) {
- pipeline(new SrpGenericResult(pipeline.evalsha(scriptSha1, numKeys, (Object[]) keysAndArgs),
- new SrpScriptReturnConverter(returnType)));
- return null;
- }
- return (T) new SrpScriptReturnConverter(returnType)
- .convert(client.evalsha(scriptSha1, numKeys, (Object[]) keysAndArgs).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public T evalSha(byte[] scriptSha1, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
- return evalSha(SrpConverters.toString(scriptSha1), returnType, numKeys, keysAndArgs);
- }
-
- //
- // Pub/Sub functionality
- //
-
- public Long publish(byte[] channel, byte[] message) {
- if (isQueueing()) {
- throw new UnsupportedOperationException();
- }
- try {
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.publish(channel, message)));
- return null;
- }
- return client.publish(channel, message).data();
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public Subscription getSubscription() {
- return subscription;
- }
-
- public boolean isSubscribed() {
- return (subscription != null && subscription.isAlive());
- }
-
- public void pSubscribe(MessageListener listener, byte[]... patterns) {
- checkSubscription();
-
- if (isQueueing()) {
- throw new UnsupportedOperationException();
- }
- if (isPipelined()) {
- throw new UnsupportedOperationException();
- }
- try {
- subscription = new SrpSubscription(listener, client);
- subscription.pSubscribe(patterns);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- public void subscribe(MessageListener listener, byte[]... channels) {
- checkSubscription();
-
- if (isPipelined()) {
- throw new UnsupportedOperationException();
- }
- try {
- subscription = new SrpSubscription(listener, client);
- subscription.subscribe(channels);
-
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoAdd(byte[], org.springframework.data.geo.Point, byte[])
- */
- @Override
- public Long geoAdd(byte[] key, Point point, byte[] member) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoAdd(byte[], org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation)
- */
- @Override
- public Long geoAdd(byte[] key, GeoLocation location) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoAdd(byte[], java.util.Map)
- */
- @Override
- public Long geoAdd(byte[] key, Map memberCoordinateMap) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoAdd(byte[], java.lang.Iterable)
- */
- @Override
- public Long geoAdd(byte[] key, Iterable> locations) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoDist(byte[], byte[], byte[])
- */
- @Override
- public Distance geoDist(byte[] key, byte[] member1, byte[] member2) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoDist(byte[], byte[], byte[], org.springframework.data.geo.Metric)
- */
- @Override
- public Distance geoDist(byte[] key, byte[] member1, byte[] member2, Metric metric) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoHash(byte[], byte[][])
- */
- @Override
- public List geoHash(byte[] key, byte[]... members) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoPos(byte[], byte[][])
- */
- @Override
- public List geoPos(byte[] key, byte[]... members) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoRadius(byte[], org.springframework.data.geo.Circle)
- */
- @Override
- public GeoResults> geoRadius(byte[] key, Circle within) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoRadius(byte[], org.springframework.data.geo.Circle, org.springframework.data.redis.core.GeoRadiusCommandArgs)
- */
- @Override
- public GeoResults> geoRadius(byte[] key, Circle within, GeoRadiusCommandArgs args) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoRadiusByMember(byte[], byte[], double)
- */
- @Override
- public GeoResults> geoRadiusByMember(byte[] key, byte[] member, double radius) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoRadiusByMember(byte[], byte[], org.springframework.data.geo.Distance)
- */
- @Override
- public GeoResults> geoRadiusByMember(byte[] key, byte[] member, Distance radius) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoRadiusByMember(byte[], byte[], org.springframework.data.geo.Distance, org.springframework.data.redis.core.GeoRadiusCommandArgs)
- */
- @Override
- public GeoResults> geoRadiusByMember(byte[] key, byte[] member, Distance radius,
- GeoRadiusCommandArgs param) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisGeoCommands#geoRemove(byte[], byte[][])
- */
- @Override
- public Long geoRemove(byte[] key, byte[]... members) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Specifies if pipelined results should be converted to the expected data type. If false, results of
- * {@link #closePipeline()} and {@link #exec()} will be of the type returned by the Lettuce driver
- *
- * @param convertPipelineAndTxResults Whether or not to convert pipeline results
- */
- public void setConvertPipelineAndTxResults(boolean convertPipelineAndTxResults) {
- this.convertPipelineAndTxResults = convertPipelineAndTxResults;
- }
-
- private void checkSubscription() {
- if (isSubscribed()) {
- throw new RedisSubscribedConnectionException(
- "Connection already subscribed; use the connection Subscription to cancel or add new channels");
- }
- }
-
- @SuppressWarnings("rawtypes")
- private void doPipelined(ListenableFuture listenableFuture) {
- pipeline(new SrpStatusResult(listenableFuture));
- }
-
- // processing method that adds a listener to the future in order to track down the results and close the pipeline
- private void pipeline(FutureResult> future) {
- if (isQueueing()) {
- txTracker.addCommand(future);
- } else {
- callback.addCommand(future);
- }
- }
-
- private void initPipeline() {
- if (pipeline == null) {
- callback = new PipelineTracker(convertPipelineAndTxResults);
- pipeline = client.pipeline();
- }
- }
-
- private void initTxTracker() {
- if (txTracker == null) {
- txTracker = new PipelineTracker(convertPipelineAndTxResults);
- }
- initPipeline();
- }
-
- public List closePipeline() {
- pipelineRequested = false;
- List results = Collections.emptyList();
- if (pipeline != null) {
- pipeline = null;
- results = getPipelinedResults(callback, true);
- callback.close();
- callback = null;
- }
- return results;
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisServerCommands#time()
- */
- @Override
- public Long time() {
-
- if (isPipelined()) {
- pipeline(new SrpGenericResult(pipeline.time(), SrpConverters.repliesToTimeAsLong()));
- return null;
- }
-
- MultiBulkReply reply = this.client.time();
- Assert.notNull(reply, "Received invalid result from server. MultiBulkReply must not be empty.");
-
- return SrpConverters.toTimeAsLong(reply.data());
- }
-
- @Override
- public void killClient(String host, int port) {
-
- Assert.hasText(host, "Host for 'CLIENT KILL' must not be 'null' or 'empty'.");
-
- String client = String.format("%s:%s", host, port);
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.client_kill(client)));
- return;
- }
-
- this.client.client_kill(client);
- } catch (Exception e) {
- throw convertSrpAccessException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisServerCommands#setClientName(byte[])
- */
- @Override
- public void setClientName(byte[] name) {
-
- try {
-
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.client_setname(name)));
- return;
- }
-
- this.client.client_setname(name);
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisServerCommands#slaveOf(java.lang.String, int)
- */
- @Override
- public void slaveOf(String host, int port) {
-
- Assert.hasText(host, "Host must not be null for 'SLAVEOF' command.");
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.slaveof(host, port)));
- return;
- }
- client.slaveof(host, port);
- } catch (Exception e) {
- throw convertSrpAccessException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisServerCommands#getClientName()
- */
- @Override
- public String getClientName() {
-
- try {
-
- if (isPipelined()) {
- pipeline(new SrpGenericResult(pipeline.client_getname(), SrpConverters.replyToString()));
- return null;
- }
-
- return SrpConverters.toString(client.client_getname());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- @Override
- public List getClientList() {
- if (isQueueing()) {
- throw new UnsupportedOperationException();
- }
- if (isPipelined()) {
- pipeline(new SrpGenericResult(pipeline.client_list(), SrpConverters.replyToListOfRedisClientInfo()));
- return null;
- }
-
- return SrpConverters.toListOfRedisClientInformation(this.client.client_list());
- }
-
- /*
- * @see org.springframework.data.redis.connection.RedisServerCommands#slaveOfNoOne()
- */
- @Override
- public void slaveOfNoOne() {
-
- try {
- if (isPipelined()) {
- pipeline(new SrpStatusResult(pipeline.slaveof("NO", "ONE")));
- return;
- }
- client.slaveof("NO", "ONE");
- } catch (Exception e) {
- throw convertSrpAccessException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisKeyCommands#scan(org.springframework.data.redis.core.ScanOptions)
- */
- @Override
- public Cursor scan(ScanOptions options) {
- throw new UnsupportedOperationException("'SCAN' command is not supported for Srp.");
- }
-
- @Override
- public Cursor zScan(byte[] key, ScanOptions options) {
- throw new UnsupportedOperationException("'ZSCAN' command is not supported for Srp.");
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisSetCommands#sScan(byte[], org.springframework.data.redis.core.ScanOptions)
- */
- @Override
- public Cursor sScan(byte[] key, ScanOptions options) {
- throw new UnsupportedOperationException("'SSCAN' command is not supported for Srp.");
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisHashCommands#hscan(byte[], org.springframework.data.redis.core.ScanOptions)
- */
- @Override
- public Cursor> hScan(byte[] key, ScanOptions options) {
- throw new UnsupportedOperationException("'HSCAN' command is not supported for Srp.");
- }
-
- private List closeTransaction() {
- List results = Collections.emptyList();
- if (txTracker != null) {
- results = getPipelinedResults(txTracker, false);
- txTracker.close();
- txTracker = null;
- }
- return results;
- }
-
- private List getPipelinedResults(PipelineTracker tracker, boolean throwPipelineException) {
- List execute = new ArrayList(tracker.complete());
- if (execute != null && !execute.isEmpty()) {
- Exception cause = null;
- for (int i = 0; i < execute.size(); i++) {
- Object object = execute.get(i);
- if (object instanceof Exception) {
- DataAccessException dataAccessException = convertSrpAccessException((Exception) object);
- if (cause == null) {
- cause = dataAccessException;
- }
- execute.set(i, dataAccessException);
- }
- }
- if (cause != null) {
- if (throwPipelineException) {
- throw new RedisPipelineException(cause, execute);
- } else {
- throw convertSrpAccessException(cause);
- }
- }
-
- return execute;
- }
- return Collections.emptyList();
- }
-
- private Object[] popArgs(int timeout, byte[]... keys) {
- int length = (keys != null ? keys.length + 1 : 1);
- Object[] args = new Object[length];
- if (keys != null) {
- for (int i = 0; i < keys.length; i++) {
- args[i] = keys[i];
- }
- }
- args[length - 1] = String.valueOf(timeout).getBytes();
- return args;
- }
-
- private Object[] limitParams(long offset, long count) {
- return new Object[] { "LIMIT".getBytes(Charsets.UTF_8), String.valueOf(offset).getBytes(Charsets.UTF_8),
- String.valueOf(count).getBytes(Charsets.UTF_8) };
- }
-
- private byte[] limit(long offset, long count) {
- return ("LIMIT " + offset + " " + count).getBytes(Charsets.UTF_8);
- }
-
- private Object[] sortParams(SortParameters params) {
- return sortParams(params, null);
- }
-
- private Object[] sortParams(SortParameters params, byte[] sortKey) {
- List arrays = new ArrayList();
- if (params != null) {
- if (params.getByPattern() != null) {
- arrays.add(BY);
- arrays.add(params.getByPattern());
- }
- if (params.getLimit() != null) {
- arrays.add(limit(params.getLimit().getStart(), params.getLimit().getCount()));
- }
- if (params.getGetPattern() != null) {
- byte[][] pattern = params.getGetPattern();
- for (byte[] bs : pattern) {
- arrays.add(GET);
- arrays.add(bs);
- }
- }
- if (params.getOrder() != null) {
- arrays.add(params.getOrder().name().getBytes(Charsets.UTF_8));
- }
- Boolean isAlpha = params.isAlphabetic();
- if (isAlpha != null && isAlpha) {
- arrays.add(ALPHA);
- }
- }
- if (sortKey != null) {
- arrays.add(STORE);
- arrays.add(sortKey);
- }
- return arrays.toArray();
- }
-
- @Override
- public Set zRangeByScore(byte[] key, String min, String max) {
-
- try {
- String keyStr = new String(key, "UTF-8");
- if (isPipelined()) {
- pipeline(new SrpResult(pipeline.zrangebyscore(keyStr, min, max, null, EMPTY_PARAMS_ARRAY),
- SrpConverters.repliesToBytesSet()));
- return null;
- }
- return SrpConverters.toBytesSet(client.zrangebyscore(keyStr, min, max, null, EMPTY_PARAMS_ARRAY).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- @Override
- public Set zRangeByScore(byte[] key, String min, String max, long offset, long count) {
-
- try {
- String keyStr = new String(key, "UTF-8");
- Object[] limit = limitParams(offset, count);
- if (isPipelined()) {
- pipeline(
- new SrpResult(pipeline.zrangebyscore(keyStr, min, max, null, limit), SrpConverters.repliesToBytesSet()));
- return null;
- }
- return SrpConverters.toBytesSet(client.zrangebyscore(keyStr, min, max, null, limit).data());
- } catch (Exception ex) {
- throw convertSrpAccessException(ex);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.HyperLogLogCommands#pfAdd(byte[], byte[][])
- */
- @Override
- public Long pfAdd(byte[] key, byte[]... values) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.HyperLogLogCommands#pfCount(byte[][])
- */
- @Override
- public Long pfCount(byte[]... keys) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.HyperLogLogCommands#pfMerge(byte[], byte[][])
- */
- @Override
- public void pfMerge(byte[] destinationKey, byte[]... sourceKeys) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zRangeByLex(byte[])
- */
- @Override
- public Set zRangeByLex(byte[] key) {
- throw new UnsupportedOperationException("ZRANGEBYLEX is no supported for srp.");
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zRangeByLex(byte[], org.springframework.data.redis.connection.RedisZSetCommands.Range)
- */
- @Override
- public Set zRangeByLex(byte[] key, Range range) {
- throw new UnsupportedOperationException("ZRANGEBYLEX is no supported for srp.");
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisZSetCommands#zRangeByLex(byte[], org.springframework.data.redis.connection.RedisZSetCommands.Range, org.springframework.data.redis.connection.RedisZSetCommands.Limit)
- */
- @Override
- public Set zRangeByLex(byte[] key, Range range, Limit limit) {
- throw new UnsupportedOperationException("ZRANGEBYLEX is no supported for srp.");
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisServerCommands#migrate(byte[], org.springframework.data.redis.connection.RedisNode, int, org.springframework.data.redis.connection.RedisServerCommands.MigrateOption)
- */
- @Override
- public void migrate(byte[] key, RedisNode target, int dbIndex, MigrateOption option) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisServerCommands#migrate(byte[], org.springframework.data.redis.connection.RedisNode, int, org.springframework.data.redis.connection.RedisServerCommands.MigrateOption, long)
- */
- @Override
- public void migrate(byte[] key, RedisNode target, int dbIndex, MigrateOption option, long timeout) {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/src/main/java/org/springframework/data/redis/connection/srp/SrpConnectionFactory.java b/src/main/java/org/springframework/data/redis/connection/srp/SrpConnectionFactory.java
deleted file mode 100644
index f0926c620..000000000
--- a/src/main/java/org/springframework/data/redis/connection/srp/SrpConnectionFactory.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2011-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.data.redis.connection.srp;
-
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.dao.DataAccessException;
-import org.springframework.data.redis.ExceptionTranslationStrategy;
-import org.springframework.data.redis.PassThroughExceptionTranslationStrategy;
-import org.springframework.data.redis.connection.RedisClusterConnection;
-import org.springframework.data.redis.connection.RedisConnection;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.connection.RedisSentinelConnection;
-
-/**
- * Connection factory creating Redis Protocol based connections.
- *
- * @author Costin Leau
- * @author Thomas Darimont
- * @deprecated since 1.7. Will be removed in subsequent version.
- */
-@Deprecated
-public class SrpConnectionFactory implements InitializingBean, DisposableBean, RedisConnectionFactory {
-
- private static final ExceptionTranslationStrategy EXCEPTION_TRANSLATION = new PassThroughExceptionTranslationStrategy(
- SrpConverters.exceptionConverter());
-
- private String hostName = "localhost";
- private int port = 6379;
- private BlockingQueue trackedConnections = new ArrayBlockingQueue(50);
- private boolean convertPipelineAndTxResults = true;
- private String password;
-
- /**
- * Constructs a new SRedisConnectionFactory instance with default settings.
- */
- public SrpConnectionFactory() {}
-
- /**
- * Constructs a new SRedisConnectionFactory instance with default settings.
- */
- public SrpConnectionFactory(String host, int port) {
- this.hostName = host;
- this.port = port;
- }
-
- public void afterPropertiesSet() {}
-
- public void destroy() {
- SrpConnection con;
- do {
- con = trackedConnections.poll();
- if (con != null && !con.isClosed()) {
- try {
- con.close();
- } catch (Exception ex) {
- // ignore
- }
- }
- } while (con != null);
- }
-
- public RedisConnection getConnection() {
- SrpConnection connection = password != null ? new SrpConnection(hostName, port, password, trackedConnections)
- : new SrpConnection(hostName, port, trackedConnections);
- connection.setConvertPipelineAndTxResults(convertPipelineAndTxResults);
- return connection;
- }
-
- /*
- * (non-Javadoc)
- * @see org.springframework.data.redis.connection.RedisConnectionFactory#getClusterConnection()
- */
- @Override
- public RedisClusterConnection getClusterConnection() {
- throw new UnsupportedOperationException("Srp does not support Redis Cluster.");
- }
-
- public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
- return EXCEPTION_TRANSLATION.translate(ex);
- }
-
- /**
- * Returns the current host.
- *
- * @return the host
- */
- public String getHostName() {
- return hostName;
- }
-
- /**
- * Sets the host.
- *
- * @param host the host to set
- */
- public void setHostName(String host) {
- this.hostName = host;
- }
-
- /**
- * Returns the current port.
- *
- * @return the port
- */
- public int getPort() {
- return port;
- }
-
- /**
- * Sets the port.
- *
- * @param port the port to set
- */
- public void setPort(int port) {
- this.port = port;
- }
-
- /**
- * Returns the password used for authenticating with the Redis server.
- *
- * @return password for authentication
- */
- public String getPassword() {
- return password;
- }
-
- /**
- * Sets the password used for authenticating with the Redis server.
- *
- * @param password the password to set
- */
- public void setPassword(String password) {
- this.password = password;
- }
-
- /**
- * Specifies if pipelined results should be converted to the expected data type. If false, results of
- * {@link SrpConnection#closePipeline()} and {@link SrpConnection#exec()} will be of the type returned by the SRP
- * driver
- *
- * @return Whether or not to convert pipeline and tx results
- */
- public boolean getConvertPipelineAndTxResults() {
- return convertPipelineAndTxResults;
- }
-
- /**
- * Specifies if pipelined results should be converted to the expected data type. If false, results of
- * {@link SrpConnection#closePipeline()} and {@link SrpConnection#exec()} will be of the type returned by the SRP
- * driver
- *
- * @param convertPipelineAndTxResults Whether or not to convert pipeline and tx results
- */
- public void setConvertPipelineAndTxResults(boolean convertPipelineAndTxResults) {
- this.convertPipelineAndTxResults = convertPipelineAndTxResults;
- }
-
- @Override
- public RedisSentinelConnection getSentinelConnection() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/src/main/java/org/springframework/data/redis/connection/srp/SrpConverters.java b/src/main/java/org/springframework/data/redis/connection/srp/SrpConverters.java
deleted file mode 100644
index dc33953f0..000000000
--- a/src/main/java/org/springframework/data/redis/connection/srp/SrpConverters.java
+++ /dev/null
@@ -1,458 +0,0 @@
-/*
- * Copyright 2013-2015 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.data.redis.connection.srp;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.springframework.core.convert.converter.Converter;
-import org.springframework.dao.DataAccessException;
-import org.springframework.data.redis.RedisConnectionFailureException;
-import org.springframework.data.redis.RedisSystemException;
-import org.springframework.data.redis.connection.DefaultTuple;
-import org.springframework.data.redis.connection.RedisListCommands.Position;
-import org.springframework.data.redis.connection.RedisStringCommands.BitOperation;
-import org.springframework.data.redis.connection.RedisZSetCommands.Range.Boundary;
-import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
-import org.springframework.data.redis.connection.convert.Converters;
-import org.springframework.data.redis.connection.convert.LongToBooleanConverter;
-import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter;
-import org.springframework.data.redis.core.types.RedisClientInfo;
-import org.springframework.util.Assert;
-
-import redis.client.RedisException;
-import redis.reply.IntegerReply;
-import redis.reply.Reply;
-
-import com.google.common.base.Charsets;
-
-/**
- * SRP type converters
- *
- * @author Jennifer Hickey
- * @author Christoph Strobl
- * @author Thomas Darimont
- * @deprecated since 1.7. Will be removed in subsequent version.
- */
-@Deprecated
-@SuppressWarnings("rawtypes")
-abstract public class SrpConverters extends Converters {
-
- private static final byte[] BEFORE = "BEFORE".getBytes(Charsets.UTF_8);
- private static final byte[] AFTER = "AFTER".getBytes(Charsets.UTF_8);
- private static final Converter> REPLIES_TO_BYTES_LIST;
- private static final Converter> REPLIES_TO_BYTES_SET;
- private static final Converter> REPLIES_TO_TUPLE_SET;
- private static final Converter> REPLIES_TO_BYTES_MAP;
- private static final Converter> REPLIES_TO_BOOLEAN_LIST;
- private static final Converter> REPLIES_TO_STRING_LIST;
- private static final Converter REPLY_TO_STRING;
- private static final Converter BYTES_TO_PROPERTIES;
- private static final Converter BYTES_TO_STRING;
- private static final Converter BYTES_TO_DOUBLE;
- private static final Converter REPLIES_TO_TIME_AS_LONG;
- private static final Converter> REPLY_T0_LIST_OF_CLIENT_INFO;
- private static final Converter> STRING_TO_LIST_OF_CLIENT_INFO = new StringToRedisClientInfoConverter();
- private static final Converter> BYTEARRAY_T0_LIST_OF_CLIENT_INFO;
- private static final Converter INTEGER_REPLY_TO_BOOLEAN;
- private static final Converter LONG_TO_BOOLEAN = new LongToBooleanConverter();
- private static final Converter EXCEPTION_CONVERTER;
-
- static {
-
- REPLIES_TO_BYTES_LIST = new Converter>() {
- public List convert(Reply[] replies) {
- if (replies == null) {
- return null;
- }
- List list = new ArrayList(replies.length);
- for (Reply reply : replies) {
- Object data = reply.data();
- if (data == null) {
- list.add(null);
- } else if (data instanceof byte[])
- list.add((byte[]) data);
- else
- throw new IllegalArgumentException("array contains more then just nulls and bytes -> " + data);
- }
- return list;
- }
- };
-
- REPLIES_TO_BYTES_SET = new Converter>() {
- public Set convert(Reply[] source) {
- return source != null ? new LinkedHashSet(SrpConverters.toBytesList(source)) : null;
- }
- };
-
- BYTES_TO_PROPERTIES = new Converter() {
- public Properties convert(byte[] source) {
- return source != null ? SrpConverters.toProperties(new String(source, Charsets.UTF_8)) : null;
- }
- };
-
- BYTES_TO_DOUBLE = new Converter() {
- public Double convert(byte[] bytes) {
- return (bytes == null || bytes.length == 0 ? null : Double.valueOf(new String(bytes, Charsets.UTF_8)));
- }
- };
-
- REPLIES_TO_TIME_AS_LONG = new Converter() {
-
- @Override
- public Long convert(Reply[] reply) {
-
- Assert.notEmpty(reply, "Received invalid result from server. Expected 2 items in collection.");
- Assert.isTrue(reply.length == 2, "Received invalid nr of arguments from redis server. Expected 2 received "
- + reply.length);
-
- List serverTimeInformation = REPLIES_TO_STRING_LIST.convert(reply);
-
- return Converters.toTimeMillis(serverTimeInformation.get(0), serverTimeInformation.get(1));
- }
-
- };
-
- REPLIES_TO_TUPLE_SET = new Converter>() {
- public Set convert(Reply[] byteArrays) {
- if (byteArrays == null) {
- return null;
- }
- Set tuples = new LinkedHashSet(byteArrays.length / 2 + 1);
- for (int i = 0; i < byteArrays.length; i++) {
- byte[] value = (byte[]) byteArrays[i].data();
- i++;
- Double score = SrpConverters.toDouble((byte[]) byteArrays[i].data());
- tuples.add(new DefaultTuple(value, score));
- }
- return tuples;
- }
- };
-
- REPLIES_TO_BYTES_MAP = new Converter>() {
- public Map convert(Reply[] byteArrays) {
- if (byteArrays == null) {
- return null;
- }
- Map map = new LinkedHashMap(byteArrays.length / 2);
- for (int i = 0; i < byteArrays.length; i++) {
- map.put((byte[]) byteArrays[i++].data(), (byte[]) byteArrays[i].data());
- }
- return map;
- }
- };
-
- BYTES_TO_STRING = new Converter() {
- public String convert(byte[] data) {
- return data != null ? new String((byte[]) data, Charsets.UTF_8) : null;
- }
- };
-
- REPLIES_TO_BOOLEAN_LIST = new Converter>() {
- public List convert(Reply[] source) {
- if (source == null) {
- return null;
- }
- List results = new ArrayList();
- for (Reply r : source) {
- results.add(SrpConverters.toBoolean(((IntegerReply) r).data()));
- }
- return results;
- }
- };
-
- REPLIES_TO_STRING_LIST = new Converter>() {
- public List convert(Reply[] source) {
- if (source == null) {
- return null;
- }
- List results = new ArrayList();
- for (Reply r : source) {
- results.add(SrpConverters.toString((byte[]) r.data()));
- }
- return results;
- }
- };
-
- REPLY_TO_STRING = new Converter() {
-
- @Override
- public String convert(Reply source) {
- if (source == null) {
- return null;
- }
- return SrpConverters.toString((byte[]) source.data());
- }
- };
-
- REPLY_T0_LIST_OF_CLIENT_INFO = new Converter>() {
-
- @Override
- public List convert(Reply source) {
-
- if (source == null || source.data() == null) {
- return Collections.emptyList();
- }
- Assert.isInstanceOf(byte[].class, source.data(), "Expected data to be an instace of byte [].");
- return BYTEARRAY_T0_LIST_OF_CLIENT_INFO.convert((byte[]) source.data());
- }
- };
-
- BYTEARRAY_T0_LIST_OF_CLIENT_INFO = new Converter>() {
-
- @Override
- public List convert(byte[] source) {
- if (source == null || source.length == 0) {
- return Collections.emptyList();
- }
-
- String s = SrpConverters.toString(source);
- return STRING_TO_LIST_OF_CLIENT_INFO.convert(s.split("\\r?\\n"));
- }
- };
-
- INTEGER_REPLY_TO_BOOLEAN = new Converter() {
-
- @Override
- public Boolean convert(IntegerReply source) {
- if (source == null || source.data() == null) {
- return false;
- }
- return source.data() == 1;
- }
- };
-
- EXCEPTION_CONVERTER = new Converter() {
-
- @Override
- public DataAccessException convert(Exception ex) {
-
- if (ex instanceof RedisException) {
- return new RedisSystemException("redis exception", ex);
- }
-
- if (ex instanceof IOException) {
- return new RedisConnectionFailureException("Redis connection failed", (IOException) ex);
- }
-
- return null;
- }
- };
- }
-
- public static Converter> repliesToBytesList() {
- return REPLIES_TO_BYTES_LIST;
- }
-
- public static Converter> repliesToBytesSet() {
- return REPLIES_TO_BYTES_SET;
- }
-
- public static Converter bytesToProperties() {
- return BYTES_TO_PROPERTIES;
- }
-
- public static Converter bytesToDouble() {
- return BYTES_TO_DOUBLE;
- }
-
- public static Converter> repliesToTupleSet() {
- return REPLIES_TO_TUPLE_SET;
- }
-
- public static Converter> repliesToBytesMap() {
- return REPLIES_TO_BYTES_MAP;
- }
-
- public static Converter