Upgrade to Jedis 3.7.
Enable support for SCAN with type, call appropriate shutdown methods with save/nosave flags. Closes: #2153 Original Pull Request: #2154
This commit is contained in:
committed by
Christoph Strobl
parent
99053cfeac
commit
a944aa2d1b
@@ -18,8 +18,10 @@ 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.ScanResult;
|
||||
import redis.clients.jedis.SortingParams;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -38,6 +40,7 @@ import org.springframework.data.redis.core.ScanIteration;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
@@ -172,10 +175,6 @@ class JedisKeyCommands implements RedisKeyCommands {
|
||||
*/
|
||||
public Cursor<byte[]> scan(long cursorId, ScanOptions options) {
|
||||
|
||||
if (options instanceof KeyScanOptions && ((KeyScanOptions) options).getType() != null) {
|
||||
throw new UnsupportedOperationException("'SCAN' with type is not yet supported using the Jedis driver");
|
||||
}
|
||||
|
||||
return new ScanCursor<byte[]>(cursorId, options) {
|
||||
|
||||
@Override
|
||||
@@ -186,8 +185,25 @@ class JedisKeyCommands implements RedisKeyCommands {
|
||||
}
|
||||
|
||||
ScanParams params = JedisConverters.toScanParams(options);
|
||||
redis.clients.jedis.ScanResult<byte[]> result = connection.getJedis().scan(Long.toString(cursorId).getBytes(),
|
||||
|
||||
ScanResult<byte[]> result;
|
||||
byte[] type = null;
|
||||
|
||||
if (options instanceof KeyScanOptions) {
|
||||
String typeAsString = ((KeyScanOptions) options).getType();
|
||||
|
||||
if (!ObjectUtils.isEmpty(typeAsString)) {
|
||||
type = typeAsString.getBytes(StandardCharsets.US_ASCII);
|
||||
}
|
||||
}
|
||||
|
||||
if (type != null) {
|
||||
result = connection.getJedis().scan(Long.toString(cursorId).getBytes(), params, type);
|
||||
} else {
|
||||
result = connection.getJedis().scan(Long.toString(cursorId).getBytes(),
|
||||
params);
|
||||
}
|
||||
|
||||
return new ScanIteration<>(Long.parseLong(result.getCursor()),
|
||||
result.getResult());
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ 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.args.SaveMode;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
@@ -25,7 +26,6 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.data.redis.connection.RedisNode;
|
||||
import org.springframework.data.redis.connection.RedisServerCommands;
|
||||
import org.springframework.data.redis.connection.ReturnType;
|
||||
import org.springframework.data.redis.connection.convert.Converters;
|
||||
import org.springframework.data.redis.core.types.RedisClientInfo;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -151,7 +151,9 @@ class JedisServerCommands implements RedisServerCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
connection.eval(String.format(SHUTDOWN_SCRIPT, option.name()).getBytes(), ReturnType.STATUS, 0);
|
||||
SaveMode saveMode = (option == ShutdownOption.NOSAVE) ? SaveMode.NOSAVE : SaveMode.SAVE;
|
||||
|
||||
connection.getJedis().shutdown(saveMode);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user