Introduce JedisInvoker.
We now use JedisInvoker to call Jedis and Pipeline methods for synchronous, pipelining, and transactional execution models. JedisInvoker captures the method invocation as functional utility and allows conversion of results: Long result = invoker.just(BinaryJedis::geoadd, MultiKeyPipelineBase:geoadd, key, point.getX(), point.getY(), member); Closes #1951 Original Pull Request: #1960
This commit is contained in:
committed by
Christoph Strobl
parent
f723bd386c
commit
c7eef8fcff
@@ -15,10 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.redis.connection.jedis;
|
package org.springframework.data.redis.connection.jedis;
|
||||||
|
|
||||||
|
import redis.clients.jedis.BinaryJedis;
|
||||||
import redis.clients.jedis.BinaryJedisPubSub;
|
import redis.clients.jedis.BinaryJedisPubSub;
|
||||||
import redis.clients.jedis.Client;
|
import redis.clients.jedis.Client;
|
||||||
import redis.clients.jedis.Connection;
|
import redis.clients.jedis.Connection;
|
||||||
import redis.clients.jedis.Jedis;
|
import redis.clients.jedis.Jedis;
|
||||||
|
import redis.clients.jedis.MultiKeyPipelineBase;
|
||||||
import redis.clients.jedis.Pipeline;
|
import redis.clients.jedis.Pipeline;
|
||||||
import redis.clients.jedis.Response;
|
import redis.clients.jedis.Response;
|
||||||
import redis.clients.jedis.Transaction;
|
import redis.clients.jedis.Transaction;
|
||||||
@@ -30,6 +32,7 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@@ -69,19 +72,25 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
JedisConverters.exceptionConverter());
|
JedisConverters.exceptionConverter());
|
||||||
|
|
||||||
private final Jedis jedis;
|
private final Jedis jedis;
|
||||||
private @Nullable Transaction transaction;
|
|
||||||
|
private final JedisInvoker invoker = new JedisInvoker((directFunction, pipelineFunction, converter,
|
||||||
|
nullDefault) -> doInvoke(false, directFunction, pipelineFunction, converter, nullDefault));
|
||||||
|
private final JedisInvoker statusInvoker = new JedisInvoker((directFunction, pipelineFunction, converter,
|
||||||
|
nullDefault) -> doInvoke(true, directFunction, pipelineFunction, converter, nullDefault));
|
||||||
|
|
||||||
private final @Nullable Pool<Jedis> pool;
|
private final @Nullable Pool<Jedis> pool;
|
||||||
/**
|
|
||||||
* flag indicating whether the connection needs to be dropped or not
|
|
||||||
*/
|
|
||||||
private volatile @Nullable JedisSubscription subscription;
|
|
||||||
private volatile @Nullable Pipeline pipeline;
|
|
||||||
private final int dbIndex;
|
private final int dbIndex;
|
||||||
private final String clientName;
|
private final String clientName;
|
||||||
private boolean convertPipelineAndTxResults = true;
|
|
||||||
private List<JedisResult> pipelinedResults = new ArrayList<>();
|
private List<JedisResult> pipelinedResults = new ArrayList<>();
|
||||||
private Queue<FutureResult<Response<?>>> txResults = new LinkedList<>();
|
private Queue<FutureResult<Response<?>>> txResults = new LinkedList<>();
|
||||||
|
|
||||||
|
private volatile @Nullable JedisSubscription subscription;
|
||||||
|
private volatile @Nullable Transaction transaction;
|
||||||
|
private volatile @Nullable Pipeline pipeline;
|
||||||
|
|
||||||
|
private boolean convertPipelineAndTxResults = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new <code>JedisConnection</code> instance.
|
* Constructs a new <code>JedisConnection</code> instance.
|
||||||
*
|
*
|
||||||
@@ -131,6 +140,37 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private Object doInvoke(boolean status, Function<Jedis, Object> directFunction,
|
||||||
|
Function<MultiKeyPipelineBase, Response<Object>> pipelineFunction, Converter<Object, Object> converter,
|
||||||
|
Supplier<Object> nullDefault) {
|
||||||
|
|
||||||
|
return doWithJedis(it -> {
|
||||||
|
|
||||||
|
if (isPipelined()) {
|
||||||
|
|
||||||
|
Response<Object> response = pipelineFunction.apply(getRequiredPipeline());
|
||||||
|
pipeline(status ? newStatusResult(response) : newJedisResult(response, converter, nullDefault));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isQueueing()) {
|
||||||
|
|
||||||
|
Response<Object> response = pipelineFunction.apply(getRequiredTransaction());
|
||||||
|
transaction(status ? newStatusResult(response) : newJedisResult(response, converter, nullDefault));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object result = directFunction.apply(getJedis());
|
||||||
|
|
||||||
|
if (result == null) {
|
||||||
|
return nullDefault.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
return converter.convert(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected DataAccessException convertJedisAccessException(Exception ex) {
|
protected DataAccessException convertJedisAccessException(Exception ex) {
|
||||||
DataAccessException exception = EXCEPTION_TRANSLATION.translate(ex);
|
DataAccessException exception = EXCEPTION_TRANSLATION.translate(ex);
|
||||||
return exception != null ? exception : new RedisSystemException(ex.getMessage(), ex);
|
return exception != null ? exception : new RedisSystemException(ex.getMessage(), ex);
|
||||||
@@ -244,15 +284,16 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
return execute(command, args, Connection::getOne, JedisClientUtils::getResponse);
|
return execute(command, args, Connection::getOne, JedisClientUtils::getResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
<T> T execute(String command, byte[][] args, Function<Client, T> resultMapper,
|
<T> T execute(String command, byte[][] args, Function<Client, T> resultMapper,
|
||||||
Function<Object, Response<?>> pipelineResponseMapper) {
|
Function<Object, Response<?>> pipelineResponseMapper) {
|
||||||
|
|
||||||
Assert.hasText(command, "A valid command needs to be specified!");
|
Assert.hasText(command, "A valid command needs to be specified!");
|
||||||
Assert.notNull(args, "Arguments must not be null!");
|
Assert.notNull(args, "Arguments must not be null!");
|
||||||
|
|
||||||
try {
|
return doWithJedis(it -> {
|
||||||
|
|
||||||
Client client = JedisClientUtils.sendCommand(command, args, this.jedis);
|
Client client = JedisClientUtils.sendCommand(command, args, it);
|
||||||
|
|
||||||
if (isQueueing() || isPipelined()) {
|
if (isQueueing() || isPipelined()) {
|
||||||
|
|
||||||
@@ -266,9 +307,7 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return resultMapper.apply(client);
|
return resultMapper.apply(client);
|
||||||
} catch (Exception ex) {
|
});
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -316,11 +355,7 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isClosed() {
|
public boolean isClosed() {
|
||||||
try {
|
return doWithJedis(it -> !it.isConnected());
|
||||||
return !jedis.isConnected();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -418,19 +453,10 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public byte[] echo(byte[] message) {
|
public byte[] echo(byte[] message) {
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
Assert.notNull(message, "Message must not be null");
|
||||||
pipeline(newJedisResult(getRequiredPipeline().echo(message)));
|
|
||||||
return null;
|
return invoke().just(BinaryJedis::echo, MultiKeyPipelineBase::echo, message);
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(newJedisResult(getRequiredTransaction().echo(message)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return jedis.echo(message);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -439,19 +465,7 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String ping() {
|
public String ping() {
|
||||||
try {
|
return invoke().just(BinaryJedis::ping, MultiKeyPipelineBase::ping);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(newJedisResult(getRequiredPipeline().ping()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(newJedisResult(getRequiredTransaction().ping()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return jedis.ping();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -540,24 +554,45 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
return jedis;
|
return jedis;
|
||||||
}
|
}
|
||||||
|
|
||||||
JedisResult newJedisResult(Response<?> response) {
|
/**
|
||||||
return JedisResultBuilder.forResponse(response).build();
|
* Obtain a {@link JedisInvoker} to call Jedis methods on the current {@link Jedis} instance.
|
||||||
|
*
|
||||||
|
* @return the {@link JedisInvoker}.
|
||||||
|
* @since 2.5
|
||||||
|
*/
|
||||||
|
JedisInvoker invoke() {
|
||||||
|
return invoker;
|
||||||
}
|
}
|
||||||
|
|
||||||
<T, R> JedisResult newJedisResult(Response<T> response, Converter<T, R> converter) {
|
/**
|
||||||
|
* Obtain a {@link JedisInvoker} to call Jedis methods returning a status response on the current {@link Jedis}
|
||||||
|
* instance. Status responses are not included in transactional and pipeline results.
|
||||||
|
*
|
||||||
|
* @return the {@link JedisInvoker}.
|
||||||
|
* @since 2.5
|
||||||
|
*/
|
||||||
|
JedisInvoker invokeStatus() {
|
||||||
|
return statusInvoker;
|
||||||
|
}
|
||||||
|
|
||||||
|
<T> JedisResult<T, T> newJedisResult(Response<T> response) {
|
||||||
|
return JedisResultBuilder.<T, T> forResponse(response).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
<T, R> JedisResult<T, R> newJedisResult(Response<T> response, Converter<T, R> converter) {
|
||||||
|
|
||||||
return JedisResultBuilder.<T, R> forResponse(response).mappedWith(converter)
|
return JedisResultBuilder.<T, R> forResponse(response).mappedWith(converter)
|
||||||
.convertPipelineAndTxResults(convertPipelineAndTxResults).build();
|
.convertPipelineAndTxResults(convertPipelineAndTxResults).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
<T, R> JedisResult newJedisResult(Response<T> response, Converter<T, R> converter, Supplier<R> defaultValue) {
|
<T, R> JedisResult<T, R> newJedisResult(Response<T> response, Converter<T, R> converter, Supplier<R> defaultValue) {
|
||||||
|
|
||||||
return JedisResultBuilder.<T, R> forResponse(response).mappedWith(converter)
|
return JedisResultBuilder.<T, R> forResponse(response).mappedWith(converter)
|
||||||
.convertPipelineAndTxResults(convertPipelineAndTxResults).mapNullTo(defaultValue).build();
|
.convertPipelineAndTxResults(convertPipelineAndTxResults).mapNullTo(defaultValue).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
JedisStatusResult newStatusResult(Response<?> response) {
|
<T> JedisStatusResult<T, T> newStatusResult(Response<T> response) {
|
||||||
return JedisResultBuilder.forResponse(response).buildStatusResult();
|
return JedisResultBuilder.<T, T> forResponse(response).buildStatusResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -569,15 +604,15 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
if (isQueueing()) {
|
if (isQueueing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
|
doWithJedis(it -> {
|
||||||
|
|
||||||
if (isPipelined()) {
|
if (isPipelined()) {
|
||||||
getRequiredPipeline().multi();
|
getRequiredPipeline().multi();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.transaction = jedis.multi();
|
this.transaction = it.multi();
|
||||||
} catch (Exception ex) {
|
});
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -586,19 +621,7 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void select(int dbIndex) {
|
public void select(int dbIndex) {
|
||||||
try {
|
invokeStatus().just(BinaryJedis::select, MultiKeyPipelineBase::select, dbIndex);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(newStatusResult(getRequiredPipeline().select(dbIndex)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(newStatusResult(getRequiredTransaction().select(dbIndex)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
jedis.select(dbIndex);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -607,11 +630,7 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void unwatch() {
|
public void unwatch() {
|
||||||
try {
|
doWithJedis((Consumer<Jedis>) BinaryJedis::unwatch);
|
||||||
jedis.unwatch();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -623,17 +642,16 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
if (isQueueing()) {
|
if (isQueueing()) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
try {
|
doWithJedis(it -> {
|
||||||
|
|
||||||
for (byte[] key : keys) {
|
for (byte[] key : keys) {
|
||||||
if (isPipelined()) {
|
if (isPipelined()) {
|
||||||
pipeline(newStatusResult(getRequiredPipeline().watch(key)));
|
pipeline(newStatusResult(getRequiredPipeline().watch(key)));
|
||||||
} else {
|
} else {
|
||||||
jedis.watch(key);
|
it.watch(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
});
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -646,19 +664,7 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long publish(byte[] channel, byte[] message) {
|
public Long publish(byte[] channel, byte[] message) {
|
||||||
try {
|
return invoke().just(BinaryJedis::publish, MultiKeyPipelineBase::publish, channel, message);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(newJedisResult(getRequiredPipeline().publish(channel, message)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(newJedisResult(getRequiredTransaction().publish(channel, message)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return jedis.publish(channel, message);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -685,26 +691,23 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void pSubscribe(MessageListener listener, byte[]... patterns) {
|
public void pSubscribe(MessageListener listener, byte[]... patterns) {
|
||||||
|
|
||||||
if (isSubscribed()) {
|
if (isSubscribed()) {
|
||||||
throw new RedisSubscribedConnectionException(
|
throw new RedisSubscribedConnectionException(
|
||||||
"Connection already subscribed; use the connection Subscription to cancel or add new channels");
|
"Connection already subscribed; use the connection Subscription to cancel or add new channels");
|
||||||
}
|
}
|
||||||
if (isQueueing()) {
|
|
||||||
throw new UnsupportedOperationException();
|
if (isQueueing() || isPipelined()) {
|
||||||
}
|
|
||||||
if (isPipelined()) {
|
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
doWithJedis(it -> {
|
||||||
|
|
||||||
BinaryJedisPubSub jedisPubSub = new JedisMessageListener(listener);
|
BinaryJedisPubSub jedisPubSub = new JedisMessageListener(listener);
|
||||||
|
|
||||||
subscription = new JedisSubscription(listener, jedisPubSub, null, patterns);
|
subscription = new JedisSubscription(listener, jedisPubSub, null, patterns);
|
||||||
jedis.psubscribe(jedisPubSub, patterns);
|
it.psubscribe(jedisPubSub, patterns);
|
||||||
|
});
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -713,27 +716,23 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(MessageListener listener, byte[]... channels) {
|
public void subscribe(MessageListener listener, byte[]... channels) {
|
||||||
|
|
||||||
if (isSubscribed()) {
|
if (isSubscribed()) {
|
||||||
throw new RedisSubscribedConnectionException(
|
throw new RedisSubscribedConnectionException(
|
||||||
"Connection already subscribed; use the connection Subscription to cancel or add new channels");
|
"Connection already subscribed; use the connection Subscription to cancel or add new channels");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isQueueing()) {
|
if (isQueueing() || isPipelined()) {
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
if (isPipelined()) {
|
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
doWithJedis(it -> {
|
||||||
|
|
||||||
BinaryJedisPubSub jedisPubSub = new JedisMessageListener(listener);
|
BinaryJedisPubSub jedisPubSub = new JedisMessageListener(listener);
|
||||||
|
|
||||||
subscription = new JedisSubscription(listener, jedisPubSub, channels, null);
|
subscription = new JedisSubscription(listener, jedisPubSub, channels, null);
|
||||||
jedis.subscribe(jedisPubSub, channels);
|
it.subscribe(jedisPubSub, channels);
|
||||||
|
});
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -753,17 +752,17 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean isActive(RedisNode node) {
|
protected boolean isActive(RedisNode node) {
|
||||||
|
|
||||||
Jedis temp = null;
|
Jedis verification = null;
|
||||||
try {
|
try {
|
||||||
temp = getJedis(node);
|
verification = getJedis(node);
|
||||||
temp.connect();
|
verification.connect();
|
||||||
return temp.ping().equalsIgnoreCase("pong");
|
return verification.ping().equalsIgnoreCase("pong");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
if (temp != null) {
|
if (verification != null) {
|
||||||
temp.disconnect();
|
verification.disconnect();
|
||||||
temp.close();
|
verification.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -788,4 +787,24 @@ public class JedisConnection extends AbstractRedisConnection {
|
|||||||
return jedis;
|
return jedis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private <T> T doWithJedis(Function<Jedis, T> callback) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
return callback.apply(getJedis());
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw convertJedisAccessException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doWithJedis(Consumer<Jedis> callback) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
callback.accept(getJedis());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw convertJedisAccessException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.redis.connection.jedis;
|
package org.springframework.data.redis.connection.jedis;
|
||||||
|
|
||||||
|
import redis.clients.jedis.BinaryJedis;
|
||||||
import redis.clients.jedis.GeoCoordinate;
|
import redis.clients.jedis.GeoCoordinate;
|
||||||
import redis.clients.jedis.GeoUnit;
|
import redis.clients.jedis.GeoUnit;
|
||||||
|
import redis.clients.jedis.MultiKeyPipelineBase;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -56,22 +58,8 @@ class JedisGeoCommands implements RedisGeoCommands {
|
|||||||
Assert.notNull(point, "Point must not be null!");
|
Assert.notNull(point, "Point must not be null!");
|
||||||
Assert.notNull(member, "Member must not be null!");
|
Assert.notNull(member, "Member must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::geoadd, MultiKeyPipelineBase::geoadd, key, point.getX(), point.getY(),
|
||||||
if (isPipelined()) {
|
member);
|
||||||
pipeline(connection
|
|
||||||
.newJedisResult(connection.getRequiredPipeline().geoadd(key, point.getX(), point.getY(), member)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection
|
|
||||||
.newJedisResult(connection.getRequiredTransaction().geoadd(key, point.getX(), point.getY(), member)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return connection.getJedis().geoadd(key, point.getX(), point.getY(), member);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -90,20 +78,7 @@ class JedisGeoCommands implements RedisGeoCommands {
|
|||||||
redisGeoCoordinateMap.put(mapKey, JedisConverters.toGeoCoordinate(memberCoordinateMap.get(mapKey)));
|
redisGeoCoordinateMap.put(mapKey, JedisConverters.toGeoCoordinate(memberCoordinateMap.get(mapKey)));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::geoadd, MultiKeyPipelineBase::geoadd, key, redisGeoCoordinateMap);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().geoadd(key, redisGeoCoordinateMap)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().geoadd(key, redisGeoCoordinateMap)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return connection.getJedis().geoadd(key, redisGeoCoordinateMap);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -122,20 +97,7 @@ class JedisGeoCommands implements RedisGeoCommands {
|
|||||||
redisGeoCoordinateMap.put(location.getName(), JedisConverters.toGeoCoordinate(location.getPoint()));
|
redisGeoCoordinateMap.put(location.getName(), JedisConverters.toGeoCoordinate(location.getPoint()));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::geoadd, MultiKeyPipelineBase::geoadd, key, redisGeoCoordinateMap);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().geoadd(key, redisGeoCoordinateMap)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().geoadd(key, redisGeoCoordinateMap)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return connection.getJedis().geoadd(key, redisGeoCoordinateMap);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -151,23 +113,8 @@ class JedisGeoCommands implements RedisGeoCommands {
|
|||||||
|
|
||||||
Converter<Double, Distance> distanceConverter = JedisConverters.distanceConverterForMetric(DistanceUnit.METERS);
|
Converter<Double, Distance> distanceConverter = JedisConverters.distanceConverterForMetric(DistanceUnit.METERS);
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::geodist, MultiKeyPipelineBase::geodist, key, member1, member2)
|
||||||
if (isPipelined()) {
|
.get(distanceConverter);
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().geodist(key, member1, member2),
|
|
||||||
distanceConverter));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().geodist(key, member1, member2),
|
|
||||||
distanceConverter));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Double distance = connection.getJedis().geodist(key, member1, member2);
|
|
||||||
return distance != null ? distanceConverter.convert(distance) : null;
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -185,23 +132,8 @@ class JedisGeoCommands implements RedisGeoCommands {
|
|||||||
GeoUnit geoUnit = JedisConverters.toGeoUnit(metric);
|
GeoUnit geoUnit = JedisConverters.toGeoUnit(metric);
|
||||||
Converter<Double, Distance> distanceConverter = JedisConverters.distanceConverterForMetric(metric);
|
Converter<Double, Distance> distanceConverter = JedisConverters.distanceConverterForMetric(metric);
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::geodist, MultiKeyPipelineBase::geodist, key, member1, member2, geoUnit)
|
||||||
if (isPipelined()) {
|
.get(distanceConverter);
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().geodist(key, member1, member2, geoUnit),
|
|
||||||
distanceConverter));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(
|
|
||||||
connection.getRequiredTransaction().geodist(key, member1, member2, geoUnit), distanceConverter));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Double distance = connection.getJedis().geodist(key, member1, member2, geoUnit);
|
|
||||||
return distance != null ? distanceConverter.convert(distance) : null;
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -215,22 +147,8 @@ class JedisGeoCommands implements RedisGeoCommands {
|
|||||||
Assert.notNull(members, "Members must not be null!");
|
Assert.notNull(members, "Members must not be null!");
|
||||||
Assert.noNullElements(members, "Members must not contain null!");
|
Assert.noNullElements(members, "Members must not contain null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::geohash, MultiKeyPipelineBase::geohash, key, members)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters.bytesListToStringListConverter());
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().geohash(key, members),
|
|
||||||
JedisConverters.bytesListToStringListConverter()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().geohash(key, members),
|
|
||||||
JedisConverters.bytesListToStringListConverter()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return JedisConverters.bytesListToStringListConverter().convert(connection.getJedis().geohash(key, members));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -245,19 +163,8 @@ class JedisGeoCommands implements RedisGeoCommands {
|
|||||||
Assert.noNullElements(members, "Members must not contain null!");
|
Assert.noNullElements(members, "Members must not contain null!");
|
||||||
|
|
||||||
ListConverter<GeoCoordinate, Point> converter = JedisConverters.geoCoordinateToPointConverter();
|
ListConverter<GeoCoordinate, Point> converter = JedisConverters.geoCoordinateToPointConverter();
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
return connection.invoke().from(BinaryJedis::geopos, MultiKeyPipelineBase::geopos, key, members).get(converter);
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().geopos(key, members), converter));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().geopos(key, members), converter));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return converter.convert(connection.getJedis().geopos(key, members));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -272,30 +179,12 @@ class JedisGeoCommands implements RedisGeoCommands {
|
|||||||
|
|
||||||
Converter<List<redis.clients.jedis.GeoRadiusResponse>, GeoResults<GeoLocation<byte[]>>> converter = JedisConverters
|
Converter<List<redis.clients.jedis.GeoRadiusResponse>, GeoResults<GeoLocation<byte[]>>> converter = JedisConverters
|
||||||
.geoRadiusResponseToGeoResultsConverter(within.getRadius().getMetric());
|
.geoRadiusResponseToGeoResultsConverter(within.getRadius().getMetric());
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(
|
|
||||||
connection.newJedisResult(
|
|
||||||
connection.getRequiredPipeline().georadius(key, within.getCenter().getX(), within.getCenter().getY(),
|
|
||||||
within.getRadius().getValue(), JedisConverters.toGeoUnit(within.getRadius().getMetric())),
|
|
||||||
converter));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(
|
|
||||||
connection.newJedisResult(
|
|
||||||
connection.getRequiredTransaction().georadius(key, within.getCenter().getX(), within.getCenter().getY(),
|
|
||||||
within.getRadius().getValue(), JedisConverters.toGeoUnit(within.getRadius().getMetric())),
|
|
||||||
converter));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return converter
|
return connection.invoke()
|
||||||
.convert(connection.getJedis().georadius(key, within.getCenter().getX(), within.getCenter().getY(),
|
.from(BinaryJedis::georadius, MultiKeyPipelineBase::georadius, key, within.getCenter().getX(),
|
||||||
within.getRadius().getValue(), JedisConverters.toGeoUnit(within.getRadius().getMetric())));
|
within.getCenter().getY(), within.getRadius().getValue(),
|
||||||
} catch (Exception ex) {
|
JedisConverters.toGeoUnit(within.getRadius().getMetric()))
|
||||||
throw convertJedisAccessException(ex);
|
.get(converter);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -313,26 +202,11 @@ class JedisGeoCommands implements RedisGeoCommands {
|
|||||||
Converter<List<redis.clients.jedis.GeoRadiusResponse>, GeoResults<GeoLocation<byte[]>>> converter = JedisConverters
|
Converter<List<redis.clients.jedis.GeoRadiusResponse>, GeoResults<GeoLocation<byte[]>>> converter = JedisConverters
|
||||||
.geoRadiusResponseToGeoResultsConverter(within.getRadius().getMetric());
|
.geoRadiusResponseToGeoResultsConverter(within.getRadius().getMetric());
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::georadius, MultiKeyPipelineBase::georadius, key,
|
||||||
if (isPipelined()) {
|
within.getCenter().getX(),
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().georadius(key, within.getCenter().getX(),
|
|
||||||
within.getCenter().getY(), within.getRadius().getValue(),
|
within.getCenter().getY(), within.getRadius().getValue(),
|
||||||
JedisConverters.toGeoUnit(within.getRadius().getMetric()), geoRadiusParam), converter));
|
JedisConverters.toGeoUnit(within.getRadius().getMetric()), geoRadiusParam)
|
||||||
return null;
|
.get(converter);
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().georadius(key,
|
|
||||||
within.getCenter().getX(), within.getCenter().getY(), within.getRadius().getValue(),
|
|
||||||
JedisConverters.toGeoUnit(within.getRadius().getMetric()), geoRadiusParam), converter));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return converter.convert(connection.getJedis().georadius(key, within.getCenter().getX(),
|
|
||||||
within.getCenter().getY(), within.getRadius().getValue(),
|
|
||||||
JedisConverters.toGeoUnit(within.getRadius().getMetric()), geoRadiusParam));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -350,22 +224,8 @@ class JedisGeoCommands implements RedisGeoCommands {
|
|||||||
Converter<List<redis.clients.jedis.GeoRadiusResponse>, GeoResults<GeoLocation<byte[]>>> converter = JedisConverters
|
Converter<List<redis.clients.jedis.GeoRadiusResponse>, GeoResults<GeoLocation<byte[]>>> converter = JedisConverters
|
||||||
.geoRadiusResponseToGeoResultsConverter(radius.getMetric());
|
.geoRadiusResponseToGeoResultsConverter(radius.getMetric());
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::georadiusByMember, MultiKeyPipelineBase::georadiusByMember, key,
|
||||||
if (isPipelined()) {
|
member, radius.getValue(), geoUnit).get(converter);
|
||||||
pipeline(connection.newJedisResult(
|
|
||||||
connection.getRequiredPipeline().georadiusByMember(key, member, radius.getValue(), geoUnit), converter));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(
|
|
||||||
connection.getRequiredTransaction().georadiusByMember(key, member, radius.getValue(), geoUnit), converter));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return converter.convert(connection.getJedis().georadiusByMember(key, member, radius.getValue(), geoUnit));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -386,23 +246,8 @@ class JedisGeoCommands implements RedisGeoCommands {
|
|||||||
.geoRadiusResponseToGeoResultsConverter(radius.getMetric());
|
.geoRadiusResponseToGeoResultsConverter(radius.getMetric());
|
||||||
redis.clients.jedis.params.GeoRadiusParam geoRadiusParam = JedisConverters.toGeoRadiusParam(args);
|
redis.clients.jedis.params.GeoRadiusParam geoRadiusParam = JedisConverters.toGeoRadiusParam(args);
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::georadiusByMember, MultiKeyPipelineBase::georadiusByMember, key,
|
||||||
if (isPipelined()) {
|
member, radius.getValue(), geoUnit, geoRadiusParam).get(converter);
|
||||||
pipeline(connection.newJedisResult(
|
|
||||||
connection.getRequiredPipeline().georadiusByMember(key, member, radius.getValue(), geoUnit, geoRadiusParam),
|
|
||||||
converter));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().georadiusByMember(key, member,
|
|
||||||
radius.getValue(), geoUnit, geoRadiusParam), converter));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return converter
|
|
||||||
.convert(connection.getJedis().georadiusByMember(key, member, radius.getValue(), geoUnit, geoRadiusParam));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -413,24 +258,4 @@ class JedisGeoCommands implements RedisGeoCommands {
|
|||||||
public Long geoRemove(byte[] key, byte[]... members) {
|
public Long geoRemove(byte[] key, byte[]... members) {
|
||||||
return connection.zSetCommands().zRem(key, members);
|
return connection.zSetCommands().zRem(key, members);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPipelined() {
|
|
||||||
return connection.isPipelined();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pipeline(JedisResult result) {
|
|
||||||
connection.pipeline(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isQueueing() {
|
|
||||||
return connection.isQueueing();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void transaction(JedisResult result) {
|
|
||||||
connection.transaction(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RuntimeException convertJedisAccessException(Exception ex) {
|
|
||||||
return connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.redis.connection.jedis;
|
package org.springframework.data.redis.connection.jedis;
|
||||||
|
|
||||||
|
import redis.clients.jedis.BinaryJedis;
|
||||||
|
import redis.clients.jedis.MultiKeyPipelineBase;
|
||||||
import redis.clients.jedis.ScanParams;
|
import redis.clients.jedis.ScanParams;
|
||||||
import redis.clients.jedis.ScanResult;
|
import redis.clients.jedis.ScanResult;
|
||||||
|
|
||||||
@@ -55,21 +57,8 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
Assert.notNull(field, "Field must not be null!");
|
Assert.notNull(field, "Field must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::hset, MultiKeyPipelineBase::hset, key, field, value)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters.longToBoolean());
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hset(key, field, value),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().hset(key, field, value),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toBoolean(connection.getJedis().hset(key, field, value));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -83,21 +72,8 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
Assert.notNull(field, "Field must not be null!");
|
Assert.notNull(field, "Field must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::hsetnx, MultiKeyPipelineBase::hsetnx, key, field, value)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters.longToBoolean());
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hsetnx(key, field, value),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().hsetnx(key, field, value),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toBoolean(connection.getJedis().hsetnx(key, field, value));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -110,19 +86,7 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(fields, "Fields must not be null!");
|
Assert.notNull(fields, "Fields must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::hdel, MultiKeyPipelineBase::hdel, key, fields);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hdel(key, fields)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().hdel(key, fields)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().hdel(key, fields);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -135,19 +99,7 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(field, "Fields must not be null!");
|
Assert.notNull(field, "Fields must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::hexists, MultiKeyPipelineBase::hexists, key, field);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hexists(key, field)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().hexists(key, field)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().hexists(key, field);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -160,19 +112,7 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(field, "Field must not be null!");
|
Assert.notNull(field, "Field must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::hget, MultiKeyPipelineBase::hget, key, field);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hget(key, field)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().hget(key, field)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().hget(key, field);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -184,19 +124,7 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::hgetAll, MultiKeyPipelineBase::hgetAll, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hgetAll(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().hgetAll(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().hgetAll(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -209,19 +137,7 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(field, "Field must not be null!");
|
Assert.notNull(field, "Field must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::hincrBy, MultiKeyPipelineBase::hincrBy, key, field, delta);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hincrBy(key, field, delta)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().hincrBy(key, field, delta)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().hincrBy(key, field, delta);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -234,19 +150,7 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(field, "Field must not be null!");
|
Assert.notNull(field, "Field must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::hincrByFloat, MultiKeyPipelineBase::hincrByFloat, key, field, delta);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hincrByFloat(key, field, delta)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().hincrByFloat(key, field, delta)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().hincrByFloat(key, field, delta);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -258,19 +162,7 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::hkeys, MultiKeyPipelineBase::hkeys, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hkeys(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().hkeys(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().hkeys(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -282,19 +174,7 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::hlen, MultiKeyPipelineBase::hlen, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hlen(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().hlen(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().hlen(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -307,19 +187,7 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(fields, "Fields must not be null!");
|
Assert.notNull(fields, "Fields must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::hmget, MultiKeyPipelineBase::hmget, key, fields);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hmget(key, fields)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().hmget(key, fields)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().hmget(key, fields);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -332,19 +200,7 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(hashes, "Hashes must not be null!");
|
Assert.notNull(hashes, "Hashes must not be null!");
|
||||||
|
|
||||||
try {
|
connection.invokeStatus().just(BinaryJedis::hmset, MultiKeyPipelineBase::hmset, key, hashes);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newStatusResult(connection.getRequiredPipeline().hmset(key, hashes)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newStatusResult(connection.getRequiredTransaction().hmset(key, hashes)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().hmset(key, hashes);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -356,19 +212,7 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::hvals, MultiKeyPipelineBase::hvals, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().hvals(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().hvals(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().hvals(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -426,26 +270,14 @@ class JedisHashCommands implements RedisHashCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(field, "Field must not be null!");
|
Assert.notNull(field, "Field must not be null!");
|
||||||
|
|
||||||
return Long.class.cast(connection.execute("HSTRLEN", key, field));
|
return connection.invoke().just(BinaryJedis::hstrlen, MultiKeyPipelineBase::hstrlen, key, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPipelined() {
|
private boolean isPipelined() {
|
||||||
return connection.isPipelined();
|
return connection.isPipelined();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pipeline(JedisResult result) {
|
|
||||||
connection.pipeline(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isQueueing() {
|
private boolean isQueueing() {
|
||||||
return connection.isQueueing();
|
return connection.isQueueing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transaction(JedisResult result) {
|
|
||||||
connection.transaction(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RuntimeException convertJedisAccessException(Exception ex) {
|
|
||||||
return connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.redis.connection.jedis;
|
package org.springframework.data.redis.connection.jedis;
|
||||||
|
|
||||||
|
import redis.clients.jedis.BinaryJedis;
|
||||||
|
import redis.clients.jedis.MultiKeyPipelineBase;
|
||||||
|
|
||||||
import org.springframework.data.redis.connection.RedisHyperLogLogCommands;
|
import org.springframework.data.redis.connection.RedisHyperLogLogCommands;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
@@ -41,19 +44,7 @@ class JedisHyperLogLogCommands implements RedisHyperLogLogCommands {
|
|||||||
Assert.notEmpty(values, "PFADD requires at least one non 'null' value.");
|
Assert.notEmpty(values, "PFADD requires at least one non 'null' value.");
|
||||||
Assert.noNullElements(values, "Values for PFADD must not contain 'null'.");
|
Assert.noNullElements(values, "Values for PFADD must not contain 'null'.");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::pfadd, MultiKeyPipelineBase::pfadd, key, values);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().pfadd(key, values)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().pfadd(key, values)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().pfadd(key, values);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -66,19 +57,7 @@ class JedisHyperLogLogCommands implements RedisHyperLogLogCommands {
|
|||||||
Assert.notEmpty(keys, "PFCOUNT requires at least one non 'null' key.");
|
Assert.notEmpty(keys, "PFCOUNT requires at least one non 'null' key.");
|
||||||
Assert.noNullElements(keys, "Keys for PFCOUNT must not contain 'null'.");
|
Assert.noNullElements(keys, "Keys for PFCOUNT must not contain 'null'.");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::pfcount, MultiKeyPipelineBase::pfcount, keys);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().pfcount(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().pfcount(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().pfcount(keys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -92,39 +71,7 @@ class JedisHyperLogLogCommands implements RedisHyperLogLogCommands {
|
|||||||
Assert.notNull(sourceKeys, "Source keys must not be null");
|
Assert.notNull(sourceKeys, "Source keys must not be null");
|
||||||
Assert.noNullElements(sourceKeys, "Keys for PFMERGE must not contain 'null'.");
|
Assert.noNullElements(sourceKeys, "Keys for PFMERGE must not contain 'null'.");
|
||||||
|
|
||||||
try {
|
connection.invoke().just(BinaryJedis::pfmerge, MultiKeyPipelineBase::pfmerge, destinationKey, sourceKeys);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().pfmerge(destinationKey, sourceKeys)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().pfmerge(destinationKey, sourceKeys)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().pfmerge(destinationKey, sourceKeys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isPipelined() {
|
|
||||||
return connection.isPipelined();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pipeline(JedisResult result) {
|
|
||||||
connection.pipeline(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isQueueing() {
|
|
||||||
return connection.isQueueing();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void transaction(JedisResult result) {
|
|
||||||
connection.transaction(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RuntimeException convertJedisAccessException(Exception ex) {
|
|
||||||
return connection.convertJedisAccessException(ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.redis.connection.jedis;
|
package org.springframework.data.redis.connection.jedis;
|
||||||
|
|
||||||
|
import redis.clients.jedis.BinaryJedis;
|
||||||
|
import redis.clients.jedis.MultiKeyPipelineBase;
|
||||||
import redis.clients.jedis.ScanParams;
|
import redis.clients.jedis.ScanParams;
|
||||||
import redis.clients.jedis.SortingParams;
|
import redis.clients.jedis.SortingParams;
|
||||||
|
|
||||||
@@ -58,19 +60,7 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::exists, MultiKeyPipelineBase::exists, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().exists(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().exists(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().exists(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -84,19 +74,7 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
Assert.notNull(keys, "Keys must not be null!");
|
Assert.notNull(keys, "Keys must not be null!");
|
||||||
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::exists, MultiKeyPipelineBase::exists, keys);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().exists(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().exists(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().exists(keys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -109,19 +87,7 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
Assert.notNull(keys, "Keys must not be null!");
|
Assert.notNull(keys, "Keys must not be null!");
|
||||||
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::del, MultiKeyPipelineBase::del, keys);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().del(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().del(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().del(keys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -134,7 +100,7 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(keys, "Keys must not be null!");
|
Assert.notNull(keys, "Keys must not be null!");
|
||||||
|
|
||||||
return Long.class.cast(connection.execute("UNLINK", keys));
|
return connection.invoke().just(BinaryJedis::unlink, MultiKeyPipelineBase::unlink, keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -146,21 +112,8 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::type, MultiKeyPipelineBase::type, key)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters.stringToDataType());
|
||||||
pipeline(
|
|
||||||
connection.newJedisResult(connection.getRequiredPipeline().type(key), JedisConverters.stringToDataType()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().type(key),
|
|
||||||
JedisConverters.stringToDataType()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toDataType(connection.getJedis().type(key));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -173,7 +126,7 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(keys, "Keys must not be null!");
|
Assert.notNull(keys, "Keys must not be null!");
|
||||||
|
|
||||||
return Long.class.cast(connection.execute("TOUCH", keys));
|
return connection.invoke().just(BinaryJedis::touch, MultiKeyPipelineBase::touch, keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -185,19 +138,7 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(pattern, "Pattern must not be null!");
|
Assert.notNull(pattern, "Pattern must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::keys, MultiKeyPipelineBase::keys, pattern);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().keys(pattern)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().keys(pattern)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().keys(pattern);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -234,7 +175,9 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
protected void doClose() {
|
protected void doClose() {
|
||||||
JedisKeyCommands.this.connection.close();
|
JedisKeyCommands.this.connection.close();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
}.open();
|
}.open();
|
||||||
}
|
}
|
||||||
@@ -245,20 +188,7 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public byte[] randomKey() {
|
public byte[] randomKey() {
|
||||||
|
return connection.invoke().just(BinaryJedis::randomBinaryKey, MultiKeyPipelineBase::randomKeyBinary);
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().randomKeyBinary()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().randomKeyBinary()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().randomBinaryKey();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -271,19 +201,7 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
Assert.notNull(sourceKey, "Source key must not be null!");
|
Assert.notNull(sourceKey, "Source key must not be null!");
|
||||||
Assert.notNull(targetKey, "Target key must not be null!");
|
Assert.notNull(targetKey, "Target key must not be null!");
|
||||||
|
|
||||||
try {
|
connection.invokeStatus().just(BinaryJedis::rename, MultiKeyPipelineBase::rename, sourceKey, targetKey);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newStatusResult(connection.getRequiredPipeline().rename(sourceKey, targetKey)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newStatusResult(connection.getRequiredTransaction().rename(sourceKey, targetKey)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().rename(sourceKey, targetKey);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -296,21 +214,8 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
Assert.notNull(sourceKey, "Source key must not be null!");
|
Assert.notNull(sourceKey, "Source key must not be null!");
|
||||||
Assert.notNull(targetKey, "Target key must not be null!");
|
Assert.notNull(targetKey, "Target key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::renamenx, MultiKeyPipelineBase::renamenx, sourceKey, targetKey)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters.longToBoolean());
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().renamenx(sourceKey, targetKey),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().renamenx(sourceKey, targetKey),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toBoolean(connection.getJedis().renamenx(sourceKey, targetKey));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -326,21 +231,8 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
return pExpire(key, TimeUnit.SECONDS.toMillis(seconds));
|
return pExpire(key, TimeUnit.SECONDS.toMillis(seconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::expire, MultiKeyPipelineBase::expire, key, (int) seconds)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters.longToBoolean());
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().expire(key, (int) seconds),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().expire(key, (int) seconds),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toBoolean(connection.getJedis().expire(key, (int) seconds));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -352,21 +244,8 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::pexpire, MultiKeyPipelineBase::pexpire, key, millis)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters.longToBoolean());
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().pexpire(key, millis),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().pexpire(key, millis),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toBoolean(connection.getJedis().pexpire(key, millis));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -378,21 +257,8 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::expireAt, MultiKeyPipelineBase::expireAt, key, unixTime)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters.longToBoolean());
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().expireAt(key, unixTime),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().expireAt(key, unixTime),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toBoolean(connection.getJedis().expireAt(key, unixTime));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -404,21 +270,8 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::pexpireAt, MultiKeyPipelineBase::pexpireAt, key, unixTimeInMillis)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters.longToBoolean());
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().pexpireAt(key, unixTimeInMillis),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().pexpireAt(key, unixTimeInMillis),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toBoolean(connection.getJedis().pexpireAt(key, unixTimeInMillis));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -430,21 +283,8 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::persist, MultiKeyPipelineBase::persist, key)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters.longToBoolean());
|
||||||
pipeline(
|
|
||||||
connection.newJedisResult(connection.getRequiredPipeline().persist(key), JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().persist(key),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toBoolean(connection.getJedis().persist(key));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -456,21 +296,8 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::move, MultiKeyPipelineBase::move, key, dbIndex)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters.longToBoolean());
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().move(key, dbIndex),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().move(key, dbIndex),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toBoolean(connection.getJedis().move(key, dbIndex));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -482,20 +309,7 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::ttl, MultiKeyPipelineBase::ttl, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().ttl(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().ttl(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return connection.getJedis().ttl(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -507,22 +321,8 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::ttl, MultiKeyPipelineBase::ttl, key)
|
||||||
if (isPipelined()) {
|
.get(Converters.secondsToTimeUnit(timeUnit));
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().ttl(key),
|
|
||||||
Converters.secondsToTimeUnit(timeUnit)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().ttl(key),
|
|
||||||
Converters.secondsToTimeUnit(timeUnit)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Converters.secondsToTimeUnit(connection.getJedis().ttl(key), timeUnit);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -534,20 +334,7 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::pttl, MultiKeyPipelineBase::pttl, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().pttl(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().pttl(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return connection.getJedis().pttl(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -559,22 +346,8 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::pttl, MultiKeyPipelineBase::pttl, key)
|
||||||
if (isPipelined()) {
|
.get(Converters.millisecondsToTimeUnit(timeUnit));
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().pttl(key),
|
|
||||||
Converters.millisecondsToTimeUnit(timeUnit)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().pttl(key),
|
|
||||||
Converters.millisecondsToTimeUnit(timeUnit)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Converters.millisecondsToTimeUnit(connection.getJedis().pttl(key), timeUnit);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -588,29 +361,11 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
SortingParams sortParams = JedisConverters.toSortingParams(params);
|
SortingParams sortParams = JedisConverters.toSortingParams(params);
|
||||||
|
|
||||||
try {
|
if (sortParams != null) {
|
||||||
if (isPipelined()) {
|
return connection.invoke().just(BinaryJedis::sort, MultiKeyPipelineBase::sort, key, sortParams);
|
||||||
if (sortParams != null) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().sort(key, sortParams)));
|
|
||||||
} else {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().sort(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
if (sortParams != null) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().sort(key, sortParams)));
|
|
||||||
} else {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().sort(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (sortParams != null ? connection.getJedis().sort(key, sortParams) : connection.getJedis().sort(key));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return connection.invoke().just(BinaryJedis::sort, MultiKeyPipelineBase::sort, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -624,30 +379,11 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
SortingParams sortParams = JedisConverters.toSortingParams(params);
|
SortingParams sortParams = JedisConverters.toSortingParams(params);
|
||||||
|
|
||||||
try {
|
if (sortParams != null) {
|
||||||
if (isPipelined()) {
|
return connection.invoke().just(BinaryJedis::sort, MultiKeyPipelineBase::sort, key, sortParams, storeKey);
|
||||||
if (sortParams != null) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().sort(key, sortParams, storeKey)));
|
|
||||||
} else {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().sort(key, storeKey)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
if (sortParams != null) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().sort(key, sortParams, storeKey)));
|
|
||||||
} else {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().sort(key, storeKey)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (sortParams != null ? connection.getJedis().sort(key, sortParams, storeKey)
|
|
||||||
: connection.getJedis().sort(key, storeKey));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return connection.invoke().just(BinaryJedis::sort, MultiKeyPipelineBase::sort, key, storeKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -659,19 +395,7 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::dump, MultiKeyPipelineBase::dump, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().dump(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().dump(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().dump(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -686,30 +410,17 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
if (replace) {
|
if (replace) {
|
||||||
|
|
||||||
this.connection.execute("RESTORE", new byte[][] { key, JedisConverters.toBytes(ttlInMillis), serializedValue,
|
connection.invokeStatus().just(BinaryJedis::restoreReplace, MultiKeyPipelineBase::restoreReplace, key,
|
||||||
JedisConverters.toBytes("REPLACE") });
|
(int) ttlInMillis, serializedValue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ttlInMillis > Integer.MAX_VALUE) {
|
if (ttlInMillis > Integer.MAX_VALUE) {
|
||||||
throw new IllegalArgumentException("TtlInMillis must be less than Integer.MAX_VALUE for restore in Jedis.");
|
throw new IllegalArgumentException("TtlInMillis must be less than Integer.MAX_VALUE for restore in Jedis.");
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection
|
|
||||||
.newStatusResult(connection.getRequiredPipeline().restore(key, (int) ttlInMillis, serializedValue)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection
|
|
||||||
.newStatusResult(connection.getRequiredTransaction().restore(key, (int) ttlInMillis, serializedValue)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().restore(key, (int) ttlInMillis, serializedValue);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
connection.invokeStatus().just(BinaryJedis::restore, MultiKeyPipelineBase::restore, key, (int) ttlInMillis,
|
||||||
|
serializedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -722,21 +433,8 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::objectEncoding, MultiKeyPipelineBase::objectEncoding, key)
|
||||||
if (isPipelined()) {
|
.getOrElse(JedisConverters::toEncoding, () -> RedisValueEncoding.VACANT);
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().objectEncoding(key),
|
|
||||||
JedisConverters::toEncoding, () -> RedisValueEncoding.VACANT));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().objectEncoding(key),
|
|
||||||
JedisConverters::toEncoding, () -> RedisValueEncoding.VACANT));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toEncoding(connection.getJedis().objectEncoding(key));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -749,22 +447,8 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::objectIdletime, MultiKeyPipelineBase::objectIdletime, key)
|
||||||
if (isPipelined()) {
|
.get(Converters::secondsToDuration);
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().objectIdletime(key),
|
|
||||||
Converters::secondsToDuration));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().objectIdletime(key),
|
|
||||||
Converters::secondsToDuration));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Converters.secondsToDuration(connection.getJedis().objectIdletime(key));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -777,35 +461,15 @@ class JedisKeyCommands implements RedisKeyCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::objectRefcount, MultiKeyPipelineBase::objectRefcount, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().objectRefcount(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().objectRefcount(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return connection.getJedis().objectRefcount(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPipelined() {
|
private boolean isPipelined() {
|
||||||
return connection.isPipelined();
|
return connection.isPipelined();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pipeline(JedisResult result) {
|
|
||||||
connection.pipeline(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isQueueing() {
|
private boolean isQueueing() {
|
||||||
return connection.isQueueing();
|
return connection.isQueueing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transaction(JedisResult result) {
|
|
||||||
connection.transaction(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.redis.connection.jedis;
|
package org.springframework.data.redis.connection.jedis;
|
||||||
|
|
||||||
|
import redis.clients.jedis.BinaryJedis;
|
||||||
|
import redis.clients.jedis.MultiKeyPipelineBase;
|
||||||
import redis.clients.jedis.Protocol;
|
import redis.clients.jedis.Protocol;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||||
@@ -47,19 +48,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::rpush, MultiKeyPipelineBase::rpush, key, values);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().rpush(key, values)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().rpush(key, values)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().rpush(key, values);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -86,19 +75,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
Assert.notNull(values, "Values must not be null!");
|
Assert.notNull(values, "Values must not be null!");
|
||||||
Assert.noNullElements(values, "Values must not contain null elements!");
|
Assert.noNullElements(values, "Values must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::lpush, MultiKeyPipelineBase::lpush, key, values);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().lpush(key, values)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().lpush(key, values)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().lpush(key, values);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -111,19 +88,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::rpushx, MultiKeyPipelineBase::rpushx, key, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().rpushx(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().rpushx(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().rpushx(key, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -136,19 +101,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::lpushx, MultiKeyPipelineBase::lpushx, key, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().lpushx(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().lpushx(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().lpushx(key, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -160,19 +113,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::llen, MultiKeyPipelineBase::llen, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().llen(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().llen(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().llen(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -184,19 +125,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::lrange, MultiKeyPipelineBase::lrange, key, start, end);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().lrange(key, start, end)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().lrange(key, start, end)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().lrange(key, start, end);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -208,19 +137,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
connection.invokeStatus().just(BinaryJedis::ltrim, MultiKeyPipelineBase::ltrim, key, start, end);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newStatusResult(connection.getRequiredPipeline().ltrim(key, start, end)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newStatusResult(connection.getRequiredTransaction().ltrim(key, start, end)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().ltrim(key, start, end);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -232,19 +149,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::lindex, MultiKeyPipelineBase::lindex, key, index);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().lindex(key, index)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().lindex(key, index)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().lindex(key, index);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -256,21 +161,8 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::linsert, MultiKeyPipelineBase::linsert, key,
|
||||||
if (isPipelined()) {
|
JedisConverters.toListPosition(where), pivot, value);
|
||||||
pipeline(connection.newJedisResult(
|
|
||||||
connection.getRequiredPipeline().linsert(key, JedisConverters.toListPosition(where), pivot, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(
|
|
||||||
connection.getRequiredTransaction().linsert(key, JedisConverters.toListPosition(where), pivot, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().linsert(key, JedisConverters.toListPosition(where), pivot, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -283,19 +175,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
connection.invokeStatus().just(BinaryJedis::lset, MultiKeyPipelineBase::lset, key, index, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newStatusResult(connection.getRequiredPipeline().lset(key, index, value)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newStatusResult(connection.getRequiredTransaction().lset(key, index, value)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().lset(key, index, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -308,19 +188,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::lrem, MultiKeyPipelineBase::lrem, key, count, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().lrem(key, count, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().lrem(key, count, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().lrem(key, count, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -332,19 +200,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::lpop, MultiKeyPipelineBase::lpop, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().lpop(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().lpop(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().lpop(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -356,20 +212,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::rpop, MultiKeyPipelineBase::rpop, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().rpop(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().rpop(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().rpop(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -382,19 +225,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
Assert.notNull(keys, "Key must not be null!");
|
Assert.notNull(keys, "Key must not be null!");
|
||||||
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::blpop, MultiKeyPipelineBase::blpop, bXPopArgs(timeout, keys));
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().blpop(bXPopArgs(timeout, keys))));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().blpop(bXPopArgs(timeout, keys))));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().blpop(timeout, keys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -407,19 +238,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
Assert.notNull(keys, "Key must not be null!");
|
Assert.notNull(keys, "Key must not be null!");
|
||||||
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::brpop, MultiKeyPipelineBase::brpop, bXPopArgs(timeout, keys));
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().brpop(bXPopArgs(timeout, keys))));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().brpop(bXPopArgs(timeout, keys))));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().brpop(timeout, keys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -432,19 +251,7 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
Assert.notNull(srcKey, "Source key must not be null!");
|
Assert.notNull(srcKey, "Source key must not be null!");
|
||||||
Assert.notNull(dstKey, "Destination key must not be null!");
|
Assert.notNull(dstKey, "Destination key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::rpoplpush, MultiKeyPipelineBase::rpoplpush, srcKey, dstKey);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().rpoplpush(srcKey, dstKey)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().rpoplpush(srcKey, dstKey)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().rpoplpush(srcKey, dstKey);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -457,48 +264,16 @@ class JedisListCommands implements RedisListCommands {
|
|||||||
Assert.notNull(srcKey, "Source key must not be null!");
|
Assert.notNull(srcKey, "Source key must not be null!");
|
||||||
Assert.notNull(dstKey, "Destination key must not be null!");
|
Assert.notNull(dstKey, "Destination key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::brpoplpush, MultiKeyPipelineBase::brpoplpush, srcKey, dstKey, timeout);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().brpoplpush(srcKey, dstKey, timeout)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().brpoplpush(srcKey, dstKey, timeout)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().brpoplpush(srcKey, dstKey, timeout);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[][] bXPopArgs(int timeout, byte[]... keys) {
|
private static byte[][] bXPopArgs(int timeout, byte[]... keys) {
|
||||||
|
|
||||||
List<byte[]> args = new ArrayList<>();
|
byte[][] args = new byte[keys.length + 1][];
|
||||||
for (byte[] arg : keys) {
|
System.arraycopy(keys, 0, args, 0, keys.length);
|
||||||
args.add(arg);
|
|
||||||
}
|
args[args.length - 1] = Protocol.toByteArray(timeout);
|
||||||
args.add(Protocol.toByteArray(timeout));
|
return args;
|
||||||
return args.toArray(new byte[args.size()][]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPipelined() {
|
|
||||||
return connection.isPipelined();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pipeline(JedisResult result) {
|
|
||||||
connection.pipeline(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isQueueing() {
|
|
||||||
return connection.isQueueing();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void transaction(JedisResult result) {
|
|
||||||
connection.transaction(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RuntimeException convertJedisAccessException(Exception ex) {
|
|
||||||
return connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ class JedisResult<T, R> extends FutureResult<Response<?>> {
|
|||||||
/**
|
/**
|
||||||
* @return a new {@link JedisStatusResult} wrapper for status results with configuration applied from this builder.
|
* @return a new {@link JedisStatusResult} wrapper for status results with configuration applied from this builder.
|
||||||
*/
|
*/
|
||||||
JedisStatusResult buildStatusResult() {
|
JedisStatusResult<T, R> buildStatusResult() {
|
||||||
return new JedisStatusResult<>(response, converter);
|
return new JedisStatusResult<>(response, converter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.data.redis.connection.ReturnType;
|
import org.springframework.data.redis.connection.ReturnType;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the value returned by Jedis script eval to the expected {@link ReturnType}
|
* Converts the value returned by Jedis script eval to the expected {@link ReturnType}
|
||||||
@@ -37,7 +38,7 @@ public class JedisScriptReturnConverter implements Converter<Object, Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Object convert(Object result) {
|
public Object convert(@Nullable Object result) {
|
||||||
if (result instanceof String) {
|
if (result instanceof String) {
|
||||||
// evalsha converts byte[] to String. Convert back for consistency
|
// evalsha converts byte[] to String. Convert back for consistency
|
||||||
return SafeEncoder.encode((String) result);
|
return SafeEncoder.encode((String) result);
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.redis.connection.jedis;
|
package org.springframework.data.redis.connection.jedis;
|
||||||
|
|
||||||
|
import redis.clients.jedis.BinaryJedis;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.redis.connection.RedisScriptingCommands;
|
import org.springframework.data.redis.connection.RedisScriptingCommands;
|
||||||
@@ -40,15 +42,9 @@ class JedisScriptingCommands implements RedisScriptingCommands {
|
|||||||
@Override
|
@Override
|
||||||
public void scriptFlush() {
|
public void scriptFlush() {
|
||||||
|
|
||||||
if (isQueueing() || isPipelined()) {
|
assertDirectMode();
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
connection.invoke().just(BinaryJedis::scriptFlush);
|
||||||
connection.getJedis().scriptFlush();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -58,15 +54,9 @@ class JedisScriptingCommands implements RedisScriptingCommands {
|
|||||||
@Override
|
@Override
|
||||||
public void scriptKill() {
|
public void scriptKill() {
|
||||||
|
|
||||||
if (isQueueing() || isPipelined()) {
|
assertDirectMode();
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
connection.invoke().just(BinaryJedis::scriptKill);
|
||||||
connection.getJedis().scriptKill();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -77,16 +67,9 @@ class JedisScriptingCommands implements RedisScriptingCommands {
|
|||||||
public String scriptLoad(byte[] script) {
|
public String scriptLoad(byte[] script) {
|
||||||
|
|
||||||
Assert.notNull(script, "Script must not be null!");
|
Assert.notNull(script, "Script must not be null!");
|
||||||
|
assertDirectMode();
|
||||||
|
|
||||||
if (isQueueing() || isPipelined()) {
|
return connection.invoke().from(it -> it.scriptLoad(script)).get(JedisConverters::toString);
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return JedisConverters.toString(connection.getJedis().scriptLoad(script));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -98,16 +81,9 @@ class JedisScriptingCommands implements RedisScriptingCommands {
|
|||||||
|
|
||||||
Assert.notNull(scriptSha1, "Script digests must not be null!");
|
Assert.notNull(scriptSha1, "Script digests must not be null!");
|
||||||
Assert.noNullElements(scriptSha1, "Script digests must not contain null elements!");
|
Assert.noNullElements(scriptSha1, "Script digests must not contain null elements!");
|
||||||
|
assertDirectMode();
|
||||||
|
|
||||||
if (isQueueing() || isPipelined()) {
|
return connection.invoke().just(it -> it.scriptExists(scriptSha1));
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return connection.getJedis().scriptExists(scriptSha1);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -119,17 +95,11 @@ class JedisScriptingCommands implements RedisScriptingCommands {
|
|||||||
public <T> T eval(byte[] script, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
|
public <T> T eval(byte[] script, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
|
||||||
|
|
||||||
Assert.notNull(script, "Script must not be null!");
|
Assert.notNull(script, "Script must not be null!");
|
||||||
|
assertDirectMode();
|
||||||
|
|
||||||
if (isQueueing() || isPipelined()) {
|
JedisScriptReturnConverter converter = new JedisScriptReturnConverter(returnType);
|
||||||
throw new UnsupportedOperationException();
|
return (T) connection.invoke().from(it -> it.eval(script, JedisConverters.toBytes(numKeys), keysAndArgs))
|
||||||
}
|
.getOrElse(converter, () -> converter.convert(null));
|
||||||
|
|
||||||
try {
|
|
||||||
return (T) new JedisScriptReturnConverter(returnType)
|
|
||||||
.convert(connection.getJedis().eval(script, JedisConverters.toBytes(numKeys), keysAndArgs));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -150,28 +120,17 @@ class JedisScriptingCommands implements RedisScriptingCommands {
|
|||||||
public <T> T evalSha(byte[] scriptSha, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
|
public <T> T evalSha(byte[] scriptSha, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
|
||||||
|
|
||||||
Assert.notNull(scriptSha, "Script digest must not be null!");
|
Assert.notNull(scriptSha, "Script digest must not be null!");
|
||||||
|
assertDirectMode();
|
||||||
|
|
||||||
if (isQueueing() || isPipelined()) {
|
JedisScriptReturnConverter converter = new JedisScriptReturnConverter(returnType);
|
||||||
throw new UnsupportedOperationException();
|
return (T) connection.invoke().from(it -> it.evalsha(scriptSha, numKeys, keysAndArgs)).getOrElse(converter,
|
||||||
}
|
() -> converter.convert(null));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
private void assertDirectMode() {
|
||||||
return (T) new JedisScriptReturnConverter(returnType)
|
if (connection.isQueueing() || connection.isPipelined()) {
|
||||||
.convert(connection.getJedis().evalsha(scriptSha, numKeys, keysAndArgs));
|
throw new UnsupportedOperationException("Scripting commands not supported in pipelining/transaction mode");
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPipelined() {
|
|
||||||
return connection.isPipelined();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isQueueing() {
|
|
||||||
return connection.isQueueing();
|
|
||||||
}
|
|
||||||
|
|
||||||
private RuntimeException convertJedisAccessException(Exception ex) {
|
|
||||||
return connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.redis.connection.jedis;
|
package org.springframework.data.redis.connection.jedis;
|
||||||
|
|
||||||
|
import redis.clients.jedis.BinaryJedis;
|
||||||
|
import redis.clients.jedis.Jedis;
|
||||||
|
import redis.clients.jedis.MultiKeyPipelineBase;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@@ -46,20 +50,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void bgReWriteAof() {
|
public void bgReWriteAof() {
|
||||||
|
connection.invoke().just(BinaryJedis::bgrewriteaof, MultiKeyPipelineBase::bgrewriteaof);
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newStatusResult(connection.getRequiredPipeline().bgrewriteaof()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newStatusResult(connection.getRequiredTransaction().bgrewriteaof()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().bgrewriteaof();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -68,20 +59,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void bgSave() {
|
public void bgSave() {
|
||||||
|
connection.invokeStatus().just(BinaryJedis::bgsave, MultiKeyPipelineBase::bgsave);
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newStatusResult(connection.getRequiredPipeline().bgsave()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newStatusResult(connection.getRequiredTransaction().bgsave()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().bgsave();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -90,20 +68,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long lastSave() {
|
public Long lastSave() {
|
||||||
|
return connection.invoke().just(BinaryJedis::lastsave, MultiKeyPipelineBase::lastsave);
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().lastsave()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().lastsave()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().lastsave();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -112,20 +77,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void save() {
|
public void save() {
|
||||||
|
connection.invokeStatus().just(BinaryJedis::save, MultiKeyPipelineBase::save);
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newStatusResult(connection.getRequiredPipeline().save()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newStatusResult(connection.getRequiredTransaction().save()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().save();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -134,20 +86,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long dbSize() {
|
public Long dbSize() {
|
||||||
|
return connection.invoke().just(BinaryJedis::dbSize, MultiKeyPipelineBase::dbSize);
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().dbSize()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().dbSize()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().dbSize();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -156,20 +95,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void flushDb() {
|
public void flushDb() {
|
||||||
|
connection.invokeStatus().just(BinaryJedis::flushDB, MultiKeyPipelineBase::flushDB);
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newStatusResult(connection.getRequiredPipeline().flushDB()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newStatusResult(connection.getRequiredTransaction().flushDB()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().flushDB();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -178,20 +104,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void flushAll() {
|
public void flushAll() {
|
||||||
|
connection.invokeStatus().just(BinaryJedis::flushAll, MultiKeyPipelineBase::flushAll);
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newStatusResult(connection.getRequiredPipeline().flushAll()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().flushAll()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().flushAll();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -200,21 +113,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Properties info() {
|
public Properties info() {
|
||||||
|
return connection.invoke().from(BinaryJedis::info, MultiKeyPipelineBase::info).get(JedisConverters::toProperties);
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().info(), JedisConverters.stringToProps()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(
|
|
||||||
connection.newJedisResult(connection.getRequiredTransaction().info(), JedisConverters.stringToProps()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toProperties(connection.getJedis().info());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -226,15 +125,8 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
|
|
||||||
Assert.notNull(section, "Section must not be null!");
|
Assert.notNull(section, "Section must not be null!");
|
||||||
|
|
||||||
if (isPipelined() || isQueueing()) {
|
return connection.invoke().from(BinaryJedis::info, MultiKeyPipelineBase::info, section)
|
||||||
throw new UnsupportedOperationException();
|
.get(JedisConverters::toProperties);
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return JedisConverters.toProperties(connection.getJedis().info(section));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -243,20 +135,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
connection.invokeStatus().just(BinaryJedis::shutdown, MultiKeyPipelineBase::shutdown);
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newStatusResult(connection.getRequiredPipeline().shutdown()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newStatusResult(connection.getRequiredTransaction().shutdown()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().shutdown();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -283,21 +162,8 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
|
|
||||||
Assert.notNull(pattern, "Pattern must not be null!");
|
Assert.notNull(pattern, "Pattern must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(Jedis::configGet, MultiKeyPipelineBase::configGet, pattern)
|
||||||
if (isPipelined()) {
|
.get(Converters::toProperties);
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().configGet(pattern),
|
|
||||||
Converters.listToPropertiesConverter()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().configGet(pattern),
|
|
||||||
Converters.listToPropertiesConverter()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return Converters.toProperties(connection.getJedis().configGet(pattern));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -310,19 +176,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
Assert.notNull(param, "Parameter must not be null!");
|
Assert.notNull(param, "Parameter must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
connection.invokeStatus().just(Jedis::configSet, MultiKeyPipelineBase::configSet, param, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newStatusResult(connection.getRequiredPipeline().configSet(param, value)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newStatusResult(connection.getRequiredTransaction().configSet(param, value)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().configSet(param, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -331,20 +185,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void resetConfigStats() {
|
public void resetConfigStats() {
|
||||||
|
connection.invokeStatus().just(BinaryJedis::configResetStat, MultiKeyPipelineBase::configResetStat);
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newStatusResult(connection.getRequiredPipeline().configResetStat()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newStatusResult(connection.getRequiredTransaction().configResetStat()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().configResetStat();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -353,21 +194,8 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Long time() {
|
public Long time() {
|
||||||
|
return connection.invoke().from(BinaryJedis::time, MultiKeyPipelineBase::time)
|
||||||
try {
|
.get(JedisConverters.toTimeConverter());
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().time(), JedisConverters.toTimeConverter()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(
|
|
||||||
connection.newJedisResult(connection.getRequiredTransaction().time(), JedisConverters.toTimeConverter()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toTimeConverter().convert(connection.getJedis().time());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -383,11 +211,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
throw new UnsupportedOperationException("'CLIENT KILL' is not supported in transaction / pipline mode.");
|
throw new UnsupportedOperationException("'CLIENT KILL' is not supported in transaction / pipline mode.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
connection.invokeStatus().just(it -> it.clientKill(String.format("%s:%s", host, port)));
|
||||||
this.connection.getJedis().clientKill(String.format("%s:%s", host, port));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw convertJedisAccessException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -403,7 +227,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
throw new UnsupportedOperationException("'CLIENT SETNAME' is not suppored in transacton / pipeline mode.");
|
throw new UnsupportedOperationException("'CLIENT SETNAME' is not suppored in transacton / pipeline mode.");
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.getJedis().clientSetname(name);
|
connection.invokeStatus().just(it -> it.clientSetname(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -417,7 +241,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return connection.getJedis().clientGetname();
|
return connection.invokeStatus().just(Jedis::clientGetname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -430,7 +254,8 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
if (isQueueing() || isPipelined()) {
|
if (isQueueing() || isPipelined()) {
|
||||||
throw new UnsupportedOperationException("'CLIENT LIST' is not supported in in pipeline / multi mode.");
|
throw new UnsupportedOperationException("'CLIENT LIST' is not supported in in pipeline / multi mode.");
|
||||||
}
|
}
|
||||||
return JedisConverters.toListOfRedisClientInformation(this.connection.getJedis().clientList());
|
|
||||||
|
return connection.invokeStatus().from(Jedis::clientList).get(JedisConverters::toListOfRedisClientInformation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -445,11 +270,8 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
if (isQueueing() || isPipelined()) {
|
if (isQueueing() || isPipelined()) {
|
||||||
throw new UnsupportedOperationException("'SLAVEOF' cannot be called in pipline / transaction mode.");
|
throw new UnsupportedOperationException("'SLAVEOF' cannot be called in pipline / transaction mode.");
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
this.connection.getJedis().slaveof(host, port);
|
connection.invokeStatus().just(it -> it.slaveof(host, port));
|
||||||
} catch (Exception e) {
|
|
||||||
throw convertJedisAccessException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -463,11 +285,7 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
throw new UnsupportedOperationException("'SLAVEOF' cannot be called in pipline / transaction mode.");
|
throw new UnsupportedOperationException("'SLAVEOF' cannot be called in pipline / transaction mode.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
connection.invokeStatus().just(BinaryJedis::slaveofNoOne);
|
||||||
this.connection.getJedis().slaveofNoOne();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw convertJedisAccessException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -491,42 +309,16 @@ class JedisServerCommands implements RedisServerCommands {
|
|||||||
|
|
||||||
int timeoutToUse = timeout <= Integer.MAX_VALUE ? (int) timeout : Integer.MAX_VALUE;
|
int timeoutToUse = timeout <= Integer.MAX_VALUE ? (int) timeout : Integer.MAX_VALUE;
|
||||||
|
|
||||||
try {
|
connection.invokeStatus().just(BinaryJedis::migrate, MultiKeyPipelineBase::migrate, target.getHost(),
|
||||||
if (isPipelined()) {
|
target.getPort(), key, dbIndex, timeoutToUse);
|
||||||
|
|
||||||
pipeline(connection.newJedisResult(
|
|
||||||
connection.getRequiredPipeline().migrate(target.getHost(), target.getPort(), key, dbIndex, timeoutToUse)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().migrate(target.getHost(),
|
|
||||||
target.getPort(), key, dbIndex, timeoutToUse)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().migrate(target.getHost(), target.getPort(), key, dbIndex, timeoutToUse);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPipelined() {
|
private boolean isPipelined() {
|
||||||
return connection.isPipelined();
|
return connection.isPipelined();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pipeline(JedisResult result) {
|
|
||||||
connection.pipeline(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isQueueing() {
|
private boolean isQueueing() {
|
||||||
return connection.isQueueing();
|
return connection.isQueueing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transaction(JedisResult result) {
|
|
||||||
connection.transaction(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RuntimeException convertJedisAccessException(Exception ex) {
|
|
||||||
return connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.redis.connection.jedis;
|
package org.springframework.data.redis.connection.jedis;
|
||||||
|
|
||||||
|
import redis.clients.jedis.BinaryJedis;
|
||||||
|
import redis.clients.jedis.MultiKeyPipelineBase;
|
||||||
import redis.clients.jedis.ScanParams;
|
import redis.clients.jedis.ScanParams;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -52,19 +54,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
Assert.notNull(values, "Values must not be null!");
|
Assert.notNull(values, "Values must not be null!");
|
||||||
Assert.noNullElements(values, "Values must not contain null elements!");
|
Assert.noNullElements(values, "Values must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::sadd, MultiKeyPipelineBase::sadd, key, values);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().sadd(key, values)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().sadd(key, values)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().sadd(key, values);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -76,19 +66,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::scard, MultiKeyPipelineBase::scard, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().scard(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().scard(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().scard(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -101,19 +79,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
Assert.notNull(keys, "Keys must not be null!");
|
Assert.notNull(keys, "Keys must not be null!");
|
||||||
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::sdiff, MultiKeyPipelineBase::sdiff, keys);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().sdiff(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().sdiff(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().sdiff(keys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -127,19 +93,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
Assert.notNull(keys, "Source keys must not be null!");
|
Assert.notNull(keys, "Source keys must not be null!");
|
||||||
Assert.noNullElements(keys, "Source keys must not contain null elements!");
|
Assert.noNullElements(keys, "Source keys must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::sdiffstore, MultiKeyPipelineBase::sdiffstore, destKey, keys);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().sdiffstore(destKey, keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().sdiffstore(destKey, keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().sdiffstore(destKey, keys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -152,19 +106,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
Assert.notNull(keys, "Keys must not be null!");
|
Assert.notNull(keys, "Keys must not be null!");
|
||||||
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::sinter, MultiKeyPipelineBase::sinter, keys);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().sinter(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().sinter(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().sinter(keys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -178,19 +120,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
Assert.notNull(keys, "Source keys must not be null!");
|
Assert.notNull(keys, "Source keys must not be null!");
|
||||||
Assert.noNullElements(keys, "Source keys must not contain null elements!");
|
Assert.noNullElements(keys, "Source keys must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::sinterstore, MultiKeyPipelineBase::sinterstore, destKey, keys);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().sinterstore(destKey, keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().sinterstore(destKey, keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().sinterstore(destKey, keys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -203,19 +133,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::sismember, MultiKeyPipelineBase::sismember, key, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().sismember(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().sismember(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().sismember(key, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -227,19 +145,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::smembers, MultiKeyPipelineBase::smembers, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().smembers(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().smembers(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().smembers(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -253,21 +159,8 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
Assert.notNull(destKey, "Destination key must not be null!");
|
Assert.notNull(destKey, "Destination key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::smove, MultiKeyPipelineBase::smove, srcKey, destKey, value)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters::toBoolean);
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().smove(srcKey, destKey, value),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().smove(srcKey, destKey, value),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toBoolean(connection.getJedis().smove(srcKey, destKey, value));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -279,19 +172,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::spop, MultiKeyPipelineBase::spop, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().spop(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().spop(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().spop(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -303,19 +184,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::spop, MultiKeyPipelineBase::spop, key, count).get(ArrayList::new);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().spop(key, count), ArrayList::new));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().spop(key, count), ArrayList::new));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new ArrayList<>(connection.getJedis().spop(key, count));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -327,19 +196,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::srandmember, MultiKeyPipelineBase::srandmember, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().srandmember(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().srandmember(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().srandmember(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -355,19 +212,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
throw new IllegalArgumentException("Count must be less than Integer.MAX_VALUE for sRandMember in Jedis.");
|
throw new IllegalArgumentException("Count must be less than Integer.MAX_VALUE for sRandMember in Jedis.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::srandmember, MultiKeyPipelineBase::srandmember, key, (int) count);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().srandmember(key, (int) count)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().srandmember(key, (int) count)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().srandmember(key, (int) count);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -381,19 +226,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
Assert.notNull(values, "Values must not be null!");
|
Assert.notNull(values, "Values must not be null!");
|
||||||
Assert.noNullElements(values, "Values must not contain null elements!");
|
Assert.noNullElements(values, "Values must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::srem, MultiKeyPipelineBase::srem, key, values);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().srem(key, values)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().srem(key, values)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().srem(key, values);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -406,19 +239,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
Assert.notNull(keys, "Keys must not be null!");
|
Assert.notNull(keys, "Keys must not be null!");
|
||||||
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::sunion, MultiKeyPipelineBase::sunion, keys);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().sunion(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().sunion(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().sunion(keys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -432,19 +253,7 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
Assert.notNull(keys, "Source keys must not be null!");
|
Assert.notNull(keys, "Source keys must not be null!");
|
||||||
Assert.noNullElements(keys, "Source keys must not contain null elements!");
|
Assert.noNullElements(keys, "Source keys must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::sunionstore, MultiKeyPipelineBase::sunionstore, destKey, keys);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().sunionstore(destKey, keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().sunionstore(destKey, keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().sunionstore(destKey, keys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -493,19 +302,8 @@ class JedisSetCommands implements RedisSetCommands {
|
|||||||
return connection.isPipelined();
|
return connection.isPipelined();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pipeline(JedisResult result) {
|
|
||||||
connection.pipeline(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isQueueing() {
|
private boolean isQueueing() {
|
||||||
return connection.isQueueing();
|
return connection.isQueueing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transaction(JedisResult result) {
|
|
||||||
connection.transaction(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RuntimeException convertJedisAccessException(Exception ex) {
|
|
||||||
return connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.redis.connection.jedis;
|
package org.springframework.data.redis.connection.jedis;
|
||||||
|
|
||||||
|
import redis.clients.jedis.BinaryJedis;
|
||||||
import redis.clients.jedis.BitPosParams;
|
import redis.clients.jedis.BitPosParams;
|
||||||
import redis.clients.jedis.Client;
|
import redis.clients.jedis.MultiKeyPipelineBase;
|
||||||
import redis.clients.jedis.params.SetParams;
|
import redis.clients.jedis.params.SetParams;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -27,7 +28,6 @@ import org.springframework.data.redis.connection.BitFieldSubCommands;
|
|||||||
import org.springframework.data.redis.connection.RedisStringCommands;
|
import org.springframework.data.redis.connection.RedisStringCommands;
|
||||||
import org.springframework.data.redis.connection.convert.Converters;
|
import org.springframework.data.redis.connection.convert.Converters;
|
||||||
import org.springframework.data.redis.core.types.Expiration;
|
import org.springframework.data.redis.core.types.Expiration;
|
||||||
import org.springframework.data.redis.util.ByteUtils;
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
@@ -54,20 +54,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::get, MultiKeyPipelineBase::get, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().get(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().get(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return connection.getJedis().get(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -80,19 +67,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::getSet, MultiKeyPipelineBase::getSet, key, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().getSet(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().getSet(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().getSet(key, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -105,19 +80,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
Assert.notNull(keys, "Keys must not be null!");
|
Assert.notNull(keys, "Keys must not be null!");
|
||||||
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
Assert.noNullElements(keys, "Keys must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::mget, MultiKeyPipelineBase::mget, keys);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().mget(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().mget(keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().mget(keys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -130,21 +93,8 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::set, MultiKeyPipelineBase::set, key, value)
|
||||||
if (isPipelined()) {
|
.get(Converters.stringToBooleanConverter());
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().set(key, value),
|
|
||||||
Converters.stringToBooleanConverter()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().set(key, value),
|
|
||||||
Converters.stringToBooleanConverter()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return Converters.stringToBoolean(connection.getJedis().set(key, value));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -162,25 +112,8 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
SetParams params = JedisConverters.toSetCommandExPxArgument(expiration,
|
SetParams params = JedisConverters.toSetCommandExPxArgument(expiration,
|
||||||
JedisConverters.toSetCommandNxXxArgument(option));
|
JedisConverters.toSetCommandNxXxArgument(option));
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::set, MultiKeyPipelineBase::set, key, value, params)
|
||||||
if (isPipelined()) {
|
.getOrElse(Converters.stringToBooleanConverter(), () -> false);
|
||||||
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().set(key, value, params),
|
|
||||||
Converters.stringToBooleanConverter(), () -> false));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().set(key, value, params),
|
|
||||||
Converters.stringToBooleanConverter(), () -> false));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Converters.stringToBoolean(connection.getJedis().set(key, value, params));
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -193,22 +126,8 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::setnx, MultiKeyPipelineBase::setnx, key, value)
|
||||||
if (isPipelined()) {
|
.get(Converters.longToBoolean());
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().setnx(key, value),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().setnx(key, value),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toBoolean(connection.getJedis().setnx(key, value));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -225,21 +144,8 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
throw new IllegalArgumentException("Time must be less than Integer.MAX_VALUE for setEx in Jedis.");
|
throw new IllegalArgumentException("Time must be less than Integer.MAX_VALUE for setEx in Jedis.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::setex, MultiKeyPipelineBase::setex, key, (int) seconds, value)
|
||||||
if (isPipelined()) {
|
.getOrElse(Converters.stringToBooleanConverter(), () -> false);
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().setex(key, (int) seconds, value),
|
|
||||||
Converters.stringToBooleanConverter(), () -> false));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().setex(key, (int) seconds, value),
|
|
||||||
Converters.stringToBooleanConverter(), () -> false));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return Converters.stringToBoolean(connection.getJedis().setex(key, (int) seconds, value));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -252,21 +158,8 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::psetex, MultiKeyPipelineBase::psetex, key, milliseconds, value)
|
||||||
if (isPipelined()) {
|
.getOrElse(Converters.stringToBooleanConverter(), () -> false);
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().psetex(key, milliseconds, value),
|
|
||||||
Converters.stringToBooleanConverter(), () -> false));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().psetex(key, milliseconds, value),
|
|
||||||
Converters.stringToBooleanConverter(), () -> false));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return Converters.stringToBoolean(connection.getJedis().psetex(key, milliseconds, value));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -278,22 +171,8 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(tuples, "Tuples must not be null!");
|
Assert.notNull(tuples, "Tuples must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::mset, MultiKeyPipelineBase::mset, JedisConverters.toByteArrays(tuples))
|
||||||
if (isPipelined()) {
|
.get(Converters.stringToBooleanConverter());
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().mset(JedisConverters.toByteArrays(tuples)),
|
|
||||||
Converters.stringToBooleanConverter()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(
|
|
||||||
connection.newJedisResult(connection.getRequiredTransaction().mset(JedisConverters.toByteArrays(tuples)),
|
|
||||||
Converters.stringToBooleanConverter()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return Converters.stringToBoolean(connection.getJedis().mset(JedisConverters.toByteArrays(tuples)));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -305,23 +184,9 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(tuples, "Tuples must not be null!");
|
Assert.notNull(tuples, "Tuples must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke()
|
||||||
if (isPipelined()) {
|
.from(BinaryJedis::msetnx, MultiKeyPipelineBase::msetnx, JedisConverters.toByteArrays(tuples))
|
||||||
pipeline(
|
.get(Converters.longToBoolean());
|
||||||
connection.newJedisResult(connection.getRequiredPipeline().msetnx(JedisConverters.toByteArrays(tuples)),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(
|
|
||||||
connection.newJedisResult(connection.getRequiredTransaction().msetnx(JedisConverters.toByteArrays(tuples)),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toBoolean(connection.getJedis().msetnx(JedisConverters.toByteArrays(tuples)));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -333,19 +198,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::incr, MultiKeyPipelineBase::incr, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().incr(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().incr(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().incr(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -357,20 +210,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::incrBy, MultiKeyPipelineBase::incrBy, key, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().incrBy(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().incrBy(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().incrBy(key, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -382,19 +222,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::incrByFloat, MultiKeyPipelineBase::incrByFloat, key, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().incrByFloat(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().incrByFloat(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().incrByFloat(key, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -406,20 +234,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::decr, MultiKeyPipelineBase::decr, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().decr(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().decr(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().decr(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -431,19 +246,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::decrBy, MultiKeyPipelineBase::decrBy, key, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().decrBy(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().decrBy(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().decrBy(key, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -456,19 +259,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::append, MultiKeyPipelineBase::append, key, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().append(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().append(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().append(key, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -480,19 +271,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::getrange, MultiKeyPipelineBase::getrange, key, start, end);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().getrange(key, start, end)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().getrange(key, start, end)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().getrange(key, start, end);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -505,19 +284,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
connection.invokeStatus().just(BinaryJedis::setrange, MultiKeyPipelineBase::setrange, key, offset, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newStatusResult(connection.getRequiredPipeline().setrange(key, offset, value)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newStatusResult(connection.getRequiredTransaction().setrange(key, offset, value)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.getJedis().setrange(key, offset, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -529,26 +296,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::getbit, MultiKeyPipelineBase::getbit, key, offset);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().getbit(key, offset)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().getbit(key, offset)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// compatibility check for Jedis 2.0.0
|
|
||||||
Object getBit = connection.getJedis().getbit(key, offset);
|
|
||||||
// Jedis 2.0
|
|
||||||
if (getBit instanceof Long) {
|
|
||||||
return (((Long) getBit) == 0 ? Boolean.FALSE : Boolean.TRUE);
|
|
||||||
}
|
|
||||||
// Jedis 2.1
|
|
||||||
return ((Boolean) getBit);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -560,23 +308,8 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::setbit, MultiKeyPipelineBase::setbit, key, offset,
|
||||||
if (isPipelined()) {
|
JedisConverters.toBit(value));
|
||||||
|
|
||||||
pipeline(connection
|
|
||||||
.newJedisResult(connection.getRequiredPipeline().setbit(key, offset, JedisConverters.toBit(value))));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection
|
|
||||||
.newJedisResult(connection.getRequiredTransaction().setbit(key, offset, JedisConverters.toBit(value))));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().setbit(key, offset, JedisConverters.toBit(value));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -588,19 +321,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::bitcount, MultiKeyPipelineBase::bitcount, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().bitcount(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().bitcount(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().bitcount(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -612,19 +333,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::bitcount, MultiKeyPipelineBase::bitcount, key, start, end);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().bitcount(key, start, end)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().bitcount(key, start, end)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().bitcount(key, start, end);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -637,9 +346,8 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(subCommands, "Command must not be null!");
|
Assert.notNull(subCommands, "Command must not be null!");
|
||||||
|
|
||||||
byte[][] args = ByteUtils.mergeArrays(key, JedisConverters.toBitfieldCommandArguments(subCommands));
|
return connection.invoke().just(BinaryJedis::bitfield, MultiKeyPipelineBase::bitfield, key,
|
||||||
|
JedisConverters.toBitfieldCommandArguments(subCommands));
|
||||||
return connection.execute("BITFIELD", args, Client::getIntegerMultiBulkReply, JedisClientUtils::getResponse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -656,21 +364,8 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
throw new UnsupportedOperationException("Bitop NOT should only be performed against one key");
|
throw new UnsupportedOperationException("Bitop NOT should only be performed against one key");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::bitop, MultiKeyPipelineBase::bitop, JedisConverters.toBitOp(op),
|
||||||
if (isPipelined()) {
|
destination, keys);
|
||||||
pipeline(connection
|
|
||||||
.newJedisResult(connection.getRequiredPipeline().bitop(JedisConverters.toBitOp(op), destination, keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection
|
|
||||||
.newJedisResult(connection.getRequiredTransaction().bitop(JedisConverters.toBitOp(op), destination, keys)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().bitop(JedisConverters.toBitOp(op), destination, keys);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -684,30 +379,16 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(range, "Range must not be null! Use Range.unbounded() instead.");
|
Assert.notNull(range, "Range must not be null! Use Range.unbounded() instead.");
|
||||||
|
|
||||||
BitPosParams params = null;
|
|
||||||
if (range.getLowerBound().isBounded()) {
|
if (range.getLowerBound().isBounded()) {
|
||||||
params = range.getUpperBound().isBounded()
|
|
||||||
|
BitPosParams params = range.getUpperBound().isBounded()
|
||||||
? new BitPosParams(range.getLowerBound().getValue().get(), range.getUpperBound().getValue().get())
|
? new BitPosParams(range.getLowerBound().getValue().get(), range.getUpperBound().getValue().get())
|
||||||
: new BitPosParams(range.getLowerBound().getValue().get());
|
: new BitPosParams(range.getLowerBound().getValue().get());
|
||||||
|
|
||||||
|
return connection.invoke().just(BinaryJedis::bitpos, MultiKeyPipelineBase::bitpos, key, bit, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::bitpos, MultiKeyPipelineBase::bitpos, key, bit);
|
||||||
if (isPipelined()) {
|
|
||||||
|
|
||||||
pipeline(connection.newJedisResult(params != null ? connection.getRequiredPipeline().bitpos(key, bit, params)
|
|
||||||
: connection.getRequiredPipeline().bitpos(key, bit)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(
|
|
||||||
connection.newJedisResult(params != null ? connection.getRequiredTransaction().bitpos(key, bit, params)
|
|
||||||
: connection.getRequiredTransaction().bitpos(key, bit)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return params != null ? connection.getJedis().bitpos(key, bit, params) : connection.getJedis().bitpos(key, bit);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -719,38 +400,7 @@ class JedisStringCommands implements RedisStringCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::strlen, MultiKeyPipelineBase::strlen, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().strlen(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().strlen(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().strlen(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPipelined() {
|
|
||||||
return connection.isPipelined();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pipeline(JedisResult result) {
|
|
||||||
connection.pipeline(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isQueueing() {
|
|
||||||
return connection.isQueueing();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void transaction(JedisResult result) {
|
|
||||||
connection.transaction(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RuntimeException convertJedisAccessException(Exception ex) {
|
|
||||||
return connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.redis.connection.jedis;
|
package org.springframework.data.redis.connection.jedis;
|
||||||
|
|
||||||
|
import redis.clients.jedis.BinaryJedis;
|
||||||
|
import redis.clients.jedis.Jedis;
|
||||||
|
import redis.clients.jedis.MultiKeyPipelineBase;
|
||||||
import redis.clients.jedis.ScanParams;
|
import redis.clients.jedis.ScanParams;
|
||||||
import redis.clients.jedis.ScanResult;
|
import redis.clients.jedis.ScanResult;
|
||||||
import redis.clients.jedis.ZParams;
|
import redis.clients.jedis.ZParams;
|
||||||
@@ -55,21 +58,8 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().from(BinaryJedis::zadd, MultiKeyPipelineBase::zadd, key, score, value)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters::toBoolean);
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zadd(key, score, value),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zadd(key, score, value),
|
|
||||||
JedisConverters.longToBoolean()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toBoolean(connection.getJedis().zadd(key, score, value));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -82,21 +72,8 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(tuples, "Tuples must not be null!");
|
Assert.notNull(tuples, "Tuples must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zadd, MultiKeyPipelineBase::zadd, key,
|
||||||
if (isPipelined()) {
|
JedisConverters.toTupleMap(tuples));
|
||||||
pipeline(
|
|
||||||
connection.newJedisResult(connection.getRequiredPipeline().zadd(key, JedisConverters.toTupleMap(tuples))));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection
|
|
||||||
.newJedisResult(connection.getRequiredTransaction().zadd(key, JedisConverters.toTupleMap(tuples))));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zadd(key, JedisConverters.toTupleMap(tuples));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -110,19 +87,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
Assert.notNull(values, "Values must not be null!");
|
Assert.notNull(values, "Values must not be null!");
|
||||||
Assert.noNullElements(values, "Values must not contain null elements!");
|
Assert.noNullElements(values, "Values must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zrem, MultiKeyPipelineBase::zrem, key, values);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrem(key, values)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrem(key, values)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zrem(key, values);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -135,19 +100,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zincrby, MultiKeyPipelineBase::zincrby, key, increment, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zincrby(key, increment, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zincrby(key, increment, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zincrby(key, increment, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -160,19 +113,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zrank, MultiKeyPipelineBase::zrank, key, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrank(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrank(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zrank(key, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -184,19 +125,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zrevrank, MultiKeyPipelineBase::zrevrank, key, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrevrank(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrevrank(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zrevrank(key, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -208,19 +137,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zrange, MultiKeyPipelineBase::zrange, key, start, end);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrange(key, start, end)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrange(key, start, end)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zrange(key, start, end);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -232,21 +149,9 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke()
|
||||||
if (isPipelined()) {
|
.from(BinaryJedis::zrangeWithScores, MultiKeyPipelineBase::zrangeWithScores, key, start, end)
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrangeWithScores(key, start, end),
|
.get(JedisConverters.tupleSetToTupleSet());
|
||||||
JedisConverters.tupleSetToTupleSet()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrangeWithScores(key, start, end),
|
|
||||||
JedisConverters.tupleSetToTupleSet()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toTupleSet(connection.getJedis().zrangeWithScores(key, start, end));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -263,38 +168,15 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES);
|
byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES);
|
||||||
byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES);
|
byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES);
|
||||||
|
|
||||||
try {
|
if (!limit.isUnlimited()) {
|
||||||
if (isPipelined()) {
|
return connection.invoke().from(BinaryJedis::zrangeByScoreWithScores,
|
||||||
if (!limit.isUnlimited()) {
|
MultiKeyPipelineBase::zrangeByScoreWithScores, key, min, max, limit.getOffset(), limit.getCount())
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrangeByScoreWithScores(key, min, max,
|
.get(JedisConverters.tupleSetToTupleSet());
|
||||||
limit.getOffset(), limit.getCount()), JedisConverters.tupleSetToTupleSet()));
|
|
||||||
} else {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrangeByScoreWithScores(key, min, max),
|
|
||||||
JedisConverters.tupleSetToTupleSet()));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isQueueing()) {
|
|
||||||
if (!limit.isUnlimited()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrangeByScoreWithScores(key, min,
|
|
||||||
max, limit.getOffset(), limit.getCount()), JedisConverters.tupleSetToTupleSet()));
|
|
||||||
} else {
|
|
||||||
transaction(
|
|
||||||
connection.newJedisResult(connection.getRequiredTransaction().zrangeByScoreWithScores(key, min, max),
|
|
||||||
JedisConverters.tupleSetToTupleSet()));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!limit.isUnlimited()) {
|
|
||||||
return JedisConverters.toTupleSet(
|
|
||||||
connection.getJedis().zrangeByScoreWithScores(key, min, max, limit.getOffset(), limit.getCount()));
|
|
||||||
}
|
|
||||||
return JedisConverters.toTupleSet(connection.getJedis().zrangeByScoreWithScores(key, min, max));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return connection.invoke()
|
||||||
|
.from(BinaryJedis::zrangeByScoreWithScores, MultiKeyPipelineBase::zrangeByScoreWithScores, key, min, max)
|
||||||
|
.get(JedisConverters.tupleSetToTupleSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -306,19 +188,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zrevrange, MultiKeyPipelineBase::zrevrange, key, start, end);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrevrange(key, start, end)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrevrange(key, start, end)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zrevrange(key, start, end);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -330,21 +200,9 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke()
|
||||||
if (isPipelined()) {
|
.from(BinaryJedis::zrevrangeWithScores, MultiKeyPipelineBase::zrevrangeWithScores, key, start, end)
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrevrangeWithScores(key, start, end),
|
.get(JedisConverters.tupleSetToTupleSet());
|
||||||
JedisConverters.tupleSetToTupleSet()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrevrangeWithScores(key, start, end),
|
|
||||||
JedisConverters.tupleSetToTupleSet()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.toTupleSet(connection.getJedis().zrevrangeWithScores(key, start, end));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -361,34 +219,13 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES);
|
byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES);
|
||||||
byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES);
|
byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES);
|
||||||
|
|
||||||
try {
|
if (!limit.isUnlimited()) {
|
||||||
if (isPipelined()) {
|
return connection.invoke().just(BinaryJedis::zrevrangeByScore, MultiKeyPipelineBase::zrevrangeByScore, key, max,
|
||||||
if (!limit.isUnlimited()) {
|
min, limit.getOffset(), limit.getCount());
|
||||||
pipeline(connection.newJedisResult(
|
|
||||||
connection.getRequiredPipeline().zrevrangeByScore(key, max, min, limit.getOffset(), limit.getCount())));
|
|
||||||
} else {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrevrangeByScore(key, max, min)));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isQueueing()) {
|
|
||||||
if (!limit.isUnlimited()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrevrangeByScore(key, max, min,
|
|
||||||
limit.getOffset(), limit.getCount())));
|
|
||||||
} else {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrevrangeByScore(key, max, min)));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!limit.isUnlimited()) {
|
|
||||||
return connection.getJedis().zrevrangeByScore(key, max, min, limit.getOffset(), limit.getCount());
|
|
||||||
}
|
|
||||||
return connection.getJedis().zrevrangeByScore(key, max, min);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return connection.invoke().just(BinaryJedis::zrevrangeByScore, MultiKeyPipelineBase::zrevrangeByScore, key, max,
|
||||||
|
min);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -405,38 +242,15 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES);
|
byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES);
|
||||||
byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES);
|
byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES);
|
||||||
|
|
||||||
try {
|
if (!limit.isUnlimited()) {
|
||||||
if (isPipelined()) {
|
return connection.invoke().from(BinaryJedis::zrevrangeByScoreWithScores,
|
||||||
if (!limit.isUnlimited()) {
|
MultiKeyPipelineBase::zrevrangeByScoreWithScores, key, max, min, limit.getOffset(), limit.getCount())
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrevrangeByScoreWithScores(key, max, min,
|
.get(JedisConverters.tupleSetToTupleSet());
|
||||||
limit.getOffset(), limit.getCount()), JedisConverters.tupleSetToTupleSet()));
|
|
||||||
} else {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrevrangeByScoreWithScores(key, max, min),
|
|
||||||
JedisConverters.tupleSetToTupleSet()));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isQueueing()) {
|
|
||||||
if (!limit.isUnlimited()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrevrangeByScoreWithScores(key, max,
|
|
||||||
min, limit.getOffset(), limit.getCount()), JedisConverters.tupleSetToTupleSet()));
|
|
||||||
} else {
|
|
||||||
transaction(
|
|
||||||
connection.newJedisResult(connection.getRequiredTransaction().zrevrangeByScoreWithScores(key, max, min),
|
|
||||||
JedisConverters.tupleSetToTupleSet()));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!limit.isUnlimited()) {
|
|
||||||
return JedisConverters.toTupleSet(
|
|
||||||
connection.getJedis().zrevrangeByScoreWithScores(key, max, min, limit.getOffset(), limit.getCount()));
|
|
||||||
}
|
|
||||||
return JedisConverters.toTupleSet(connection.getJedis().zrevrangeByScoreWithScores(key, max, min));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return connection.invoke()
|
||||||
|
.from(BinaryJedis::zrevrangeByScoreWithScores, MultiKeyPipelineBase::zrevrangeByScoreWithScores, key, max, min)
|
||||||
|
.get(JedisConverters.tupleSetToTupleSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -448,19 +262,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zcount, MultiKeyPipelineBase::zcount, key, min, max);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zcount(key, min, max)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zcount(key, min, max)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zcount(key, min, max);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -476,19 +278,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES);
|
byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES);
|
||||||
byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES);
|
byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES);
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zcount, MultiKeyPipelineBase::zcount, key, min, max);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zcount(key, min, max)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zcount(key, min, max)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zcount(key, min, max);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -504,19 +294,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
byte[] min = JedisConverters.boundaryToBytesForZRangeByLex(range.getMin(), JedisConverters.MINUS_BYTES);
|
byte[] min = JedisConverters.boundaryToBytesForZRangeByLex(range.getMin(), JedisConverters.MINUS_BYTES);
|
||||||
byte[] max = JedisConverters.boundaryToBytesForZRangeByLex(range.getMax(), JedisConverters.PLUS_BYTES);
|
byte[] max = JedisConverters.boundaryToBytesForZRangeByLex(range.getMax(), JedisConverters.PLUS_BYTES);
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zlexcount, MultiKeyPipelineBase::zlexcount, key, min, max);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zlexcount(key, min, max)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zlexcount(key, min, max)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zlexcount(key, min, max);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -528,19 +306,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zcard, MultiKeyPipelineBase::zcard, key);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zcard(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zcard(key)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zcard(key);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -553,19 +319,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
Assert.notNull(value, "Value must not be null!");
|
Assert.notNull(value, "Value must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zscore, MultiKeyPipelineBase::zscore, key, value);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zscore(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zscore(key, value)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zscore(key, value);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -577,19 +331,8 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zremrangeByRank, MultiKeyPipelineBase::zremrangeByRank, key, start,
|
||||||
if (isPipelined()) {
|
end);
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zremrangeByRank(key, start, end)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zremrangeByRank(key, start, end)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zremrangeByRank(key, start, end);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -605,19 +348,8 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES);
|
byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES);
|
||||||
byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES);
|
byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES);
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zremrangeByScore, MultiKeyPipelineBase::zremrangeByScore, key, min,
|
||||||
if (isPipelined()) {
|
max);
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zremrangeByScore(key, min, max)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zremrangeByScore(key, min, max)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zremrangeByScore(key, min, max);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -634,21 +366,10 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
Assert.isTrue(weights.size() == sets.length, () -> String
|
Assert.isTrue(weights.size() == sets.length, () -> String
|
||||||
.format("The number of weights (%d) must match the number of source sets (%d)!", weights.size(), sets.length));
|
.format("The number of weights (%d) must match the number of source sets (%d)!", weights.size(), sets.length));
|
||||||
|
|
||||||
try {
|
ZParams zparams = new ZParams().weights(weights.toArray()).aggregate(ZParams.Aggregate.valueOf(aggregate.name()));
|
||||||
ZParams zparams = new ZParams().weights(weights.toArray()).aggregate(ZParams.Aggregate.valueOf(aggregate.name()));
|
|
||||||
|
|
||||||
if (isPipelined()) {
|
return connection.invoke().just(BinaryJedis::zunionstore, MultiKeyPipelineBase::zunionstore, destKey, zparams,
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zunionstore(destKey, zparams, sets)));
|
sets);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zunionstore(destKey, zparams, sets)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zunionstore(destKey, zparams, sets);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -662,19 +383,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
Assert.notNull(sets, "Source sets must not be null!");
|
Assert.notNull(sets, "Source sets must not be null!");
|
||||||
Assert.noNullElements(sets, "Source sets must not contain null elements!");
|
Assert.noNullElements(sets, "Source sets must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zunionstore, MultiKeyPipelineBase::zunionstore, destKey, sets);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zunionstore(destKey, sets)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zunionstore(destKey, sets)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zunionstore(destKey, sets);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -690,21 +399,10 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
Assert.isTrue(weights.size() == sets.length, () -> String
|
Assert.isTrue(weights.size() == sets.length, () -> String
|
||||||
.format("The number of weights (%d) must match the number of source sets (%d)!", weights.size(), sets.length));
|
.format("The number of weights (%d) must match the number of source sets (%d)!", weights.size(), sets.length));
|
||||||
|
|
||||||
try {
|
ZParams zparams = new ZParams().weights(weights.toArray()).aggregate(ZParams.Aggregate.valueOf(aggregate.name()));
|
||||||
ZParams zparams = new ZParams().weights(weights.toArray()).aggregate(ZParams.Aggregate.valueOf(aggregate.name()));
|
|
||||||
|
|
||||||
if (isPipelined()) {
|
return connection.invoke().just(BinaryJedis::zinterstore, MultiKeyPipelineBase::zinterstore, destKey, zparams,
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zinterstore(destKey, zparams, sets)));
|
sets);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zinterstore(destKey, zparams, sets)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zinterstore(destKey, zparams, sets);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -718,19 +416,7 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
Assert.notNull(sets, "Source sets must not be null!");
|
Assert.notNull(sets, "Source sets must not be null!");
|
||||||
Assert.noNullElements(sets, "Source sets must not contain null elements!");
|
Assert.noNullElements(sets, "Source sets must not contain null elements!");
|
||||||
|
|
||||||
try {
|
return connection.invoke().just(BinaryJedis::zinterstore, MultiKeyPipelineBase::zinterstore, destKey, sets);
|
||||||
if (isPipelined()) {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zinterstore(destKey, sets)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zinterstore(destKey, sets)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return connection.getJedis().zinterstore(destKey, sets);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -787,20 +473,9 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
|
|
||||||
Assert.notNull(key, "Key must not be null!");
|
Assert.notNull(key, "Key must not be null!");
|
||||||
|
|
||||||
try {
|
String keyStr = new String(key, StandardCharsets.UTF_8);
|
||||||
String keyStr = new String(key, StandardCharsets.UTF_8);
|
return connection.invoke().from(Jedis::zrangeByScore, MultiKeyPipelineBase::zrangeByScore, keyStr, min, max)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters.stringSetToByteSet());
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrangeByScore(keyStr, min, max)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrangeByScore(keyStr, min, max)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.stringSetToByteSet().convert(connection.getJedis().zrangeByScore(keyStr, min, max));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -817,24 +492,11 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Offset and count must be less than Integer.MAX_VALUE for zRangeByScore in Jedis.");
|
"Offset and count must be less than Integer.MAX_VALUE for zRangeByScore in Jedis.");
|
||||||
}
|
}
|
||||||
|
String keyStr = new String(key, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
try {
|
return connection.invoke()
|
||||||
String keyStr = new String(key, StandardCharsets.UTF_8);
|
.from(Jedis::zrangeByScore, MultiKeyPipelineBase::zrangeByScore, keyStr, min, max, (int) offset, (int) count)
|
||||||
if (isPipelined()) {
|
.get(JedisConverters.stringSetToByteSet());
|
||||||
pipeline(connection.newJedisResult(
|
|
||||||
connection.getRequiredPipeline().zrangeByScore(keyStr, min, max, (int) offset, (int) count)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (isQueueing()) {
|
|
||||||
transaction(connection.newJedisResult(
|
|
||||||
connection.getRequiredTransaction().zrangeByScore(keyStr, min, max, (int) offset, (int) count)));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return JedisConverters.stringSetToByteSet()
|
|
||||||
.convert(connection.getJedis().zrangeByScore(keyStr, min, max, (int) offset, (int) count));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -851,34 +513,12 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES);
|
byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES);
|
||||||
byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES);
|
byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES);
|
||||||
|
|
||||||
try {
|
if (!limit.isUnlimited()) {
|
||||||
if (isPipelined()) {
|
return connection.invoke().just(BinaryJedis::zrangeByScore, MultiKeyPipelineBase::zrangeByScore, key, min, max,
|
||||||
if (!limit.isUnlimited()) {
|
limit.getOffset(), limit.getCount());
|
||||||
pipeline(connection.newJedisResult(
|
|
||||||
connection.getRequiredPipeline().zrangeByScore(key, min, max, limit.getOffset(), limit.getCount())));
|
|
||||||
} else {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrangeByScore(key, min, max)));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isQueueing()) {
|
|
||||||
if (!limit.isUnlimited()) {
|
|
||||||
transaction(connection.newJedisResult(
|
|
||||||
connection.getRequiredTransaction().zrangeByScore(key, min, max, limit.getOffset(), limit.getCount())));
|
|
||||||
} else {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrangeByScore(key, min, max)));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!limit.isUnlimited()) {
|
|
||||||
return connection.getJedis().zrangeByScore(key, min, max, limit.getOffset(), limit.getCount());
|
|
||||||
}
|
|
||||||
return connection.getJedis().zrangeByScore(key, min, max);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return connection.invoke().just(BinaryJedis::zrangeByScore, MultiKeyPipelineBase::zrangeByScore, key, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -895,34 +535,12 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
byte[] min = JedisConverters.boundaryToBytesForZRangeByLex(range.getMin(), JedisConverters.MINUS_BYTES);
|
byte[] min = JedisConverters.boundaryToBytesForZRangeByLex(range.getMin(), JedisConverters.MINUS_BYTES);
|
||||||
byte[] max = JedisConverters.boundaryToBytesForZRangeByLex(range.getMax(), JedisConverters.PLUS_BYTES);
|
byte[] max = JedisConverters.boundaryToBytesForZRangeByLex(range.getMax(), JedisConverters.PLUS_BYTES);
|
||||||
|
|
||||||
try {
|
if (!limit.isUnlimited()) {
|
||||||
if (isPipelined()) {
|
return connection.invoke().just(BinaryJedis::zrangeByLex, MultiKeyPipelineBase::zrangeByLex, key, min, max,
|
||||||
if (!limit.isUnlimited()) {
|
limit.getOffset(), limit.getCount());
|
||||||
pipeline(connection.newJedisResult(
|
|
||||||
connection.getRequiredPipeline().zrangeByLex(key, min, max, limit.getOffset(), limit.getCount())));
|
|
||||||
} else {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrangeByLex(key, min, max)));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isQueueing()) {
|
|
||||||
if (!limit.isUnlimited()) {
|
|
||||||
transaction(connection.newJedisResult(
|
|
||||||
connection.getRequiredTransaction().zrangeByLex(key, min, max, limit.getOffset(), limit.getCount())));
|
|
||||||
} else {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrangeByLex(key, min, max)));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!limit.isUnlimited()) {
|
|
||||||
return connection.getJedis().zrangeByLex(key, min, max, limit.getOffset(), limit.getCount());
|
|
||||||
}
|
|
||||||
return connection.getJedis().zrangeByLex(key, min, max);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return connection.invoke().just(BinaryJedis::zrangeByLex, MultiKeyPipelineBase::zrangeByLex, key, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -939,54 +557,22 @@ class JedisZSetCommands implements RedisZSetCommands {
|
|||||||
byte[] min = JedisConverters.boundaryToBytesForZRangeByLex(range.getMin(), JedisConverters.MINUS_BYTES);
|
byte[] min = JedisConverters.boundaryToBytesForZRangeByLex(range.getMin(), JedisConverters.MINUS_BYTES);
|
||||||
byte[] max = JedisConverters.boundaryToBytesForZRangeByLex(range.getMax(), JedisConverters.PLUS_BYTES);
|
byte[] max = JedisConverters.boundaryToBytesForZRangeByLex(range.getMax(), JedisConverters.PLUS_BYTES);
|
||||||
|
|
||||||
try {
|
|
||||||
if (isPipelined()) {
|
|
||||||
if (!limit.isUnlimited()) {
|
|
||||||
pipeline(connection.newJedisResult(
|
|
||||||
connection.getRequiredPipeline().zrevrangeByLex(key, max, min, limit.getOffset(), limit.getCount())));
|
|
||||||
} else {
|
|
||||||
pipeline(connection.newJedisResult(connection.getRequiredPipeline().zrevrangeByLex(key, max, min)));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isQueueing()) {
|
if (!limit.isUnlimited()) {
|
||||||
if (!limit.isUnlimited()) {
|
return connection.invoke().from(BinaryJedis::zrevrangeByLex, MultiKeyPipelineBase::zrevrangeByLex, key, max, min,
|
||||||
transaction(connection.newJedisResult(
|
limit.getOffset(), limit.getCount()).get(LinkedHashSet::new);
|
||||||
connection.getRequiredTransaction().zrevrangeByLex(key, max, min, limit.getOffset(), limit.getCount())));
|
|
||||||
} else {
|
|
||||||
transaction(connection.newJedisResult(connection.getRequiredTransaction().zrevrangeByLex(key, max, min)));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!limit.isUnlimited()) {
|
|
||||||
return new LinkedHashSet<>(
|
|
||||||
connection.getJedis().zrevrangeByLex(key, max, min, limit.getOffset(), limit.getCount()));
|
|
||||||
}
|
|
||||||
return new LinkedHashSet<>(connection.getJedis().zrevrangeByLex(key, max, min));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw convertJedisAccessException(ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return connection.invoke().from(BinaryJedis::zrevrangeByLex, MultiKeyPipelineBase::zrevrangeByLex, key, max, min)
|
||||||
|
.get(LinkedHashSet::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPipelined() {
|
private boolean isPipelined() {
|
||||||
return connection.isPipelined();
|
return connection.isPipelined();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pipeline(JedisResult result) {
|
|
||||||
connection.pipeline(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isQueueing() {
|
private boolean isQueueing() {
|
||||||
return connection.isQueueing();
|
return connection.isQueueing();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transaction(JedisResult result) {
|
|
||||||
connection.transaction(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RuntimeException convertJedisAccessException(Exception ex) {
|
|
||||||
return connection.convertJedisAccessException(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,11 +216,6 @@ public class JedisConnectionPipelineIntegrationTests extends AbstractConnectionP
|
|||||||
@Disabled
|
@Disabled
|
||||||
public void testScriptFlush() {}
|
public void testScriptFlush() {}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testInfoBySection() {
|
|
||||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(super::testInfoBySection);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test // DATAREDIS-269
|
@Test // DATAREDIS-269
|
||||||
public void clientSetNameWorksCorrectly() {
|
public void clientSetNameWorksCorrectly() {
|
||||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(super::clientSetNameWorksCorrectly);
|
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(super::clientSetNameWorksCorrectly);
|
||||||
|
|||||||
@@ -28,10 +28,6 @@ import org.junit.jupiter.api.Test;
|
|||||||
*/
|
*/
|
||||||
public class JedisConnectionPipelineTxIntegrationTests extends JedisConnectionTransactionIntegrationTests {
|
public class JedisConnectionPipelineTxIntegrationTests extends JedisConnectionTransactionIntegrationTests {
|
||||||
|
|
||||||
@Disabled("Jedis issue: Pipeline tries to return String instead of List<String>")
|
|
||||||
@Test
|
|
||||||
public void testGetConfig() {}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Disabled
|
@Disabled
|
||||||
public void testRestoreBadData() {}
|
public void testRestoreBadData() {}
|
||||||
|
|||||||
Reference in New Issue
Block a user