Remove deprecated API.

See: #2273
Original Pull Request: #2276
This commit is contained in:
Mark Paluch
2022-02-23 11:17:04 +01:00
committed by Christoph Strobl
parent b45d358abf
commit 5c4c9e029f
36 changed files with 39 additions and 1355 deletions

View File

@@ -17,7 +17,6 @@ package org.springframework.data.redis.cache;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Optional;
import java.util.function.Consumer;
import org.springframework.cache.Cache;
@@ -143,25 +142,6 @@ public class RedisCacheConfiguration {
valueSerializationPair, conversionService);
}
/**
* Use the given prefix instead of using the cache name. <br />
* This option replaces the cache name with {@code prefix} therefore we recommend rather using
* {@link #prefixCacheNameWith(String)} or {@link #computePrefixWith(CacheKeyPrefix)} for more control. <br />
* The generated cache key will be: {@code prefix + cache entry key}.
*
* @param prefix must not be {@literal null}.
* @return new {@link RedisCacheConfiguration}.
* @deprecated since 2.3. Use {@link #prefixCacheNameWith(String)} or {@link #computePrefixWith(CacheKeyPrefix)}
* instead.
*/
@Deprecated
public RedisCacheConfiguration prefixKeysWith(String prefix) {
Assert.notNull(prefix, "Prefix must not be null!");
return computePrefixWith((cacheName) -> prefix);
}
/**
* Prefix the {@link RedisCache#getName() cache name} with the given value. <br />
* The generated cache key will be: {@code prefix + cache name + "::" + cache entry key}.
@@ -261,15 +241,6 @@ public class RedisCacheConfiguration {
valueSerializationPair, conversionService);
}
/**
* @return never {@literal null}.
* @deprecated since 2.0.4. Please use {@link #getKeyPrefixFor(String)}.
*/
@Deprecated
public Optional<String> getKeyPrefix() {
return usePrefix() ? Optional.of(keyPrefix.compute("")) : Optional.empty();
}
/**
* Get the computed {@literal key} prefix for a given {@literal cacheName}.
*

View File

@@ -15,7 +15,6 @@
*/
package org.springframework.data.redis.connection;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -32,8 +31,6 @@ public class ClusterCommandExecutionFailureException extends UncategorizedDataAc
private static final long serialVersionUID = 5727044227040368955L;
private final Collection<? extends Throwable> causes;
/**
* Creates new {@link ClusterCommandExecutionFailureException}.
*
@@ -51,18 +48,8 @@ public class ClusterCommandExecutionFailureException extends UncategorizedDataAc
public ClusterCommandExecutionFailureException(List<? extends Throwable> causes) {
super(causes.get(0).getMessage(), causes.get(0));
this.causes = causes;
causes.forEach(this::addSuppressed);
}
/**
* Get the collected errors.
*
* @return never {@literal null}.
* @deprecated since 2.0, use {@link #getSuppressed()}.
*/
public Collection<? extends Throwable> getCauses() {
return causes;
}
}

View File

@@ -199,14 +199,6 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco
delegate.bgReWriteAof();
}
/**
* @deprecated As of 1.3, use {@link #bgReWriteAof}.
*/
@Deprecated
public void bgWriteAof() {
bgReWriteAof();
}
@Override
public List<byte[]> bLPop(int timeout, byte[]... keys) {
return convertAndReturn(delegate.bLPop(timeout, keys), Converters.identityConverter());

View File

@@ -1590,13 +1590,6 @@ public interface DefaultedRedisConnection extends RedisConnection {
// SERVER COMMANDS
/** @deprecated in favor of {@link RedisConnection#serverCommands()}. */
@Override
@Deprecated
default void bgWriteAof() {
serverCommands().bgWriteAof();
}
/** @deprecated in favor of {@link RedisConnection#serverCommands()}. */
@Override
@Deprecated

View File

@@ -1,45 +0,0 @@
/*
* Copyright 2011-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.connection;
/**
* Pool of resources
*
* @author Jennifer Hickey
*/
public interface Pool<T> {
/**
* @return A resource, if available
*/
T getResource();
/**
* @param resource A broken resource that should be invalidated
*/
void returnBrokenResource(final T resource);
/**
* @param resource A resource to return to the pool
*/
void returnResource(final T resource);
/**
* Destroys the pool
*/
void destroy();
}

View File

@@ -1,37 +0,0 @@
/*
* Copyright 2013-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.connection;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
/**
* Subclass of {@link GenericObjectPoolConfig} that includes setters for instantiation in Spring
*
* @author Jennifer Hickey
* @author Christoph Strobl
* @deprecated use {@link GenericObjectPoolConfig} instead. Will be removed in a future revision.
*/
@Deprecated
public class PoolConfig extends GenericObjectPoolConfig {
public PoolConfig() {
super();
}
public void setMaxActive(int maxActive) {
setMaxTotal(maxActive);
}
}

View File

@@ -346,16 +346,6 @@ public interface ReactiveKeyCommands {
return new RenameCommand(getKey(), newKey);
}
/**
* @return can be {@literal null}.
* @deprecated since 2.5.7, renamed to {@link #getNewKey()}.
*/
@Nullable
@Deprecated
public ByteBuffer getNewName() {
return newKey;
}
/**
* @return can be {@literal null}.
* @since 2.5.7

View File

@@ -51,17 +51,6 @@ public interface RedisServerCommands {
SYNC, ASYNC
}
/**
* Start an {@literal Append Only File} rewrite process on server.
*
* @deprecated As of 1.3, use {@link #bgReWriteAof}.
* @see <a href="https://redis.io/commands/bgrewriteaof">Redis Documentation: BGREWRITEAOF</a>
*/
@Deprecated
default void bgWriteAof() {
bgReWriteAof();
}
/**
* Start an {@literal Append Only File} rewrite process on server.
*

View File

@@ -76,7 +76,7 @@ import org.springframework.util.Assert;
public class JedisClusterConnection implements DefaultedRedisClusterConnection {
private static final ExceptionTranslationStrategy EXCEPTION_TRANSLATION = new FallbackExceptionTranslationStrategy(
JedisConverters.exceptionConverter());
JedisExceptionConverter.INSTANCE);
private static final byte[][] EMPTY_2D_BYTE_ARRAY = new byte[0][];

View File

@@ -61,7 +61,7 @@ import org.springframework.util.CollectionUtils;
public class JedisConnection extends AbstractRedisConnection {
private static final ExceptionTranslationStrategy EXCEPTION_TRANSLATION = new FallbackExceptionTranslationStrategy(
JedisConverters.exceptionConverter());
JedisExceptionConverter.INSTANCE);
private final Jedis jedis;
@@ -417,7 +417,7 @@ public class JedisConnection extends AbstractRedisConnection {
try {
if (isPipelined()) {
pipeline(newJedisResult(getRequiredPipeline().exec(),
new TransactionResultConverter<>(new LinkedList<>(txResults), JedisConverters.exceptionConverter())));
new TransactionResultConverter<>(new LinkedList<>(txResults), JedisExceptionConverter.INSTANCE)));
return null;
}
@@ -428,7 +428,7 @@ public class JedisConnection extends AbstractRedisConnection {
List<Object> results = transaction.exec();
return !CollectionUtils.isEmpty(results)
? new TransactionResultConverter<>(txResults, JedisConverters.exceptionConverter()).convert(results)
? new TransactionResultConverter<>(txResults, JedisExceptionConverter.INSTANCE).convert(results)
: results;
} catch (Exception ex) {
throw convertJedisAccessException(ex);

View File

@@ -61,7 +61,6 @@ import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
* Connection factory creating <a href="https://github.com/xetorthio/jedis">Jedis</a> based connections.
@@ -90,12 +89,10 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
private final static Log log = LogFactory.getLog(JedisConnectionFactory.class);
private static final ExceptionTranslationStrategy EXCEPTION_TRANSLATION = new PassThroughExceptionTranslationStrategy(
JedisConverters.exceptionConverter());
JedisExceptionConverter.INSTANCE);
private final JedisClientConfiguration clientConfiguration;
private @Nullable JedisShardInfo shardInfo;
private JedisClientConfig clientConfig = DefaultJedisClientConfig.builder().build();
private boolean providedShardInfo = false;
private @Nullable Pool<Jedis> pool;
private boolean convertPipelineAndTxResults = true;
private RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration("localhost",
@@ -131,23 +128,6 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
this.clientConfiguration = clientConfig;
}
/**
* Constructs a new <code>JedisConnectionFactory</code> instance. Will override the other connection parameters passed
* to the factory.
*
* @param shardInfo shard information
* @deprecated since 2.0, configure Jedis with {@link JedisClientConfiguration} and
* {@link RedisStandaloneConfiguration}.
*/
@Deprecated
public JedisConnectionFactory(JedisShardInfo shardInfo) {
this(MutableJedisClientConfiguration.create(shardInfo));
this.shardInfo = shardInfo;
this.providedShardInfo = true;
}
/**
* Constructs a new <code>JedisConnectionFactory</code> instance using the given pool configuration.
*
@@ -176,7 +156,7 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
* @param poolConfig pool configuration. Defaulted to new instance if {@literal null}.
* @since 1.4
*/
public JedisConnectionFactory(RedisSentinelConfiguration sentinelConfig, JedisPoolConfig poolConfig) {
public JedisConnectionFactory(RedisSentinelConfiguration sentinelConfig, @Nullable JedisPoolConfig poolConfig) {
this.configuration = sentinelConfig;
this.clientConfiguration = MutableJedisClientConfiguration
@@ -295,10 +275,6 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
private Jedis createJedis() {
if (providedShardInfo) {
return new Jedis(getShardInfo());
}
return new Jedis(new HostAndPort(getHostName(), getPort()), this.clientConfig);
}
@@ -317,29 +293,6 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
clientConfig = createClientConfig(getDatabase(), getRedisUsername(), getRedisPassword());
if (shardInfo == null && clientConfiguration instanceof MutableJedisClientConfiguration) {
providedShardInfo = false;
shardInfo = new JedisShardInfo(getHostName(), getPort(), isUseSsl(), //
clientConfiguration.getSslSocketFactory().orElse(null), //
clientConfiguration.getSslParameters().orElse(null), //
clientConfiguration.getHostnameVerifier().orElse(null));
getRedisPassword().map(String::new).ifPresent(shardInfo::setPassword);
String username = getRedisUsername();
if (StringUtils.hasText(username)) {
shardInfo.setUser(username);
}
int readTimeout = getReadTimeout();
if (readTimeout > 0) {
shardInfo.setSoTimeout(readTimeout);
}
getMutableConfiguration().setShardInfo(shardInfo);
}
if (getUsePool() && !isRedisClusterAware()) {
this.pool = createPool();
}
@@ -630,34 +583,6 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
standaloneConfig.setPort(port);
}
/**
* Returns the shardInfo.
*
* @return the shardInfo.
* @deprecated since 2.0.
*/
@Deprecated
@Nullable
public JedisShardInfo getShardInfo() {
return shardInfo;
}
/**
* Sets the shard info for this factory.
*
* @param shardInfo the shardInfo to set.
* @deprecated since 2.0, configure the individual properties from {@link JedisShardInfo} using
* {@link JedisClientConfiguration}.
* @throws IllegalStateException if {@link JedisClientConfiguration} is immutable.
*/
@Deprecated
public void setShardInfo(JedisShardInfo shardInfo) {
this.shardInfo = shardInfo;
this.providedShardInfo = true;
getMutableConfiguration().setShardInfo(shardInfo);
}
/**
* Returns the timeout.
*
@@ -968,7 +893,6 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
public static JedisClientConfiguration create(JedisShardInfo shardInfo) {
MutableJedisClientConfiguration configuration = new MutableJedisClientConfiguration();
configuration.setShardInfo(shardInfo);
return configuration;
}
@@ -1060,14 +984,5 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean,
this.connectTimeout = connectTimeout;
}
public void setShardInfo(JedisShardInfo shardInfo) {
setSslSocketFactory(shardInfo.getSslSocketFactory());
setSslParameters(shardInfo.getSslParameters());
setHostnameVerifier(shardInfo.getHostnameVerifier());
setUseSsl(shardInfo.getSsl());
setConnectTimeout(Duration.ofMillis(shardInfo.getConnectionTimeout()));
setReadTimeout(Duration.ofMillis(shardInfo.getSoTimeout()));
}
}
}

View File

@@ -41,7 +41,6 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.springframework.core.convert.converter.Converter;
import org.springframework.dao.DataAccessException;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.GeoResult;
import org.springframework.data.geo.GeoResults;
@@ -70,7 +69,6 @@ import org.springframework.data.redis.connection.SortParameters.Range;
import org.springframework.data.redis.connection.ValueEncoding;
import org.springframework.data.redis.connection.convert.Converters;
import org.springframework.data.redis.connection.convert.ListConverter;
import org.springframework.data.redis.connection.convert.MapConverter;
import org.springframework.data.redis.connection.convert.SetConverter;
import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter;
import org.springframework.data.redis.connection.zset.DefaultTuple;
@@ -95,10 +93,9 @@ import org.springframework.util.StringUtils;
* @author Guy Korland
* @author dengliming
*/
@SuppressWarnings("ConstantConditions")
public abstract class JedisConverters extends Converters {
private static final Converter<Exception, DataAccessException> EXCEPTION_CONVERTER = new JedisExceptionConverter();
public static final byte[] PLUS_BYTES;
public static final byte[] MINUS_BYTES;
public static final byte[] POSITIVE_INFINITY_BYTES;
@@ -122,56 +119,19 @@ public abstract class JedisConverters extends Converters {
* @return
* @since 1.4
*/
public static ListConverter<redis.clients.jedis.Tuple, Tuple> tuplesToTuples() {
static ListConverter<redis.clients.jedis.Tuple, Tuple> tuplesToTuples() {
return new ListConverter<>(JedisConverters::toTuple);
}
public static ListConverter<String, byte[]> stringListToByteList() {
static ListConverter<String, byte[]> stringListToByteList() {
return new ListConverter<>(stringToBytes());
}
/**
* @deprecated since 2.5
*/
@Deprecated
public static SetConverter<String, byte[]> stringSetToByteSet() {
return new SetConverter<>(stringToBytes());
}
/**
* @deprecated since 2.5
*/
@Deprecated
public static MapConverter<String, byte[]> stringMapToByteMap() {
return new MapConverter<>(stringToBytes());
}
/**
* @deprecated since 2.5
*/
@Deprecated
public static SetConverter<redis.clients.jedis.Tuple, Tuple> tupleSetToTupleSet() {
return new SetConverter<>(JedisConverters::toTuple);
}
public static Converter<Exception, DataAccessException> exceptionConverter() {
return EXCEPTION_CONVERTER;
}
public static String[] toStrings(byte[][] source) {
String[] result = new String[source.length];
for (int i = 0; i < source.length; i++) {
result[i] = SafeEncoder.encode(source[i]);
}
return result;
}
/**
* @deprecated since 2.5
*/
@Deprecated
public static Set<Tuple> toTupleSet(Set<redis.clients.jedis.Tuple> source) {
return tupleSetToTupleSet().convert(source);
static Set<Tuple> toTupleSet(Set<redis.clients.jedis.Tuple> source) {
return new SetConverter<>(JedisConverters::toTuple).convert(source);
}
public static Tuple toTuple(redis.clients.jedis.Tuple source) {
@@ -192,18 +152,8 @@ public abstract class JedisConverters extends Converters {
Map<byte[], Double> args = new LinkedHashMap<>(tuples.size(), 1);
Set<Double> scores = new HashSet<>(tuples.size(), 1);
boolean isAtLeastJedis24 = JedisVersionUtil.atLeastJedis24();
for (Tuple tuple : tuples) {
if (!isAtLeastJedis24) {
if (scores.contains(tuple.getScore())) {
throw new UnsupportedOperationException(
"Bulk add of multiple elements with the same score is not supported. Add the elements individually.");
}
scores.add(tuple.getScore());
}
scores.add(tuple.getScore());
args.put(tuple.getValue(), tuple.getScore());
}
@@ -292,14 +242,6 @@ public abstract class JedisConverters extends Converters {
return toList(it -> RedisServer.newServerFrom(Converters.toProperties(it)), source);
}
/**
* @deprecated since 2.5
*/
@Deprecated
public static DataAccessException toDataAccessException(Exception ex) {
return EXCEPTION_CONVERTER.convert(ex);
}
public static ListPosition toListPosition(Position source) {
Assert.notNull(source, "list positions are mandatory");
return (Position.AFTER.equals(source) ? ListPosition.AFTER : ListPosition.BEFORE);
@@ -609,26 +551,9 @@ public abstract class JedisConverters extends Converters {
return target;
}
/**
* @deprecated since 2.5
*/
@Deprecated
public static ListConverter<byte[], String> bytesListToStringListConverter() {
return new ListConverter<>(JedisConverters::toString);
}
/**
* @deprecated since 2.5
*/
@Deprecated
public static ListConverter<byte[], Long> getBytesListToLongListConverter() {
return new ListConverter<>(JedisConverters::toLong);
}
/**
* @return
* @since 1.8
* @deprecated since 2.5
*/
public static ListConverter<redis.clients.jedis.GeoCoordinate, Point> geoCoordinateToPointConverter() {
return new ListConverter<>(JedisConverters::toPoint);

View File

@@ -41,6 +41,8 @@ import org.springframework.data.redis.TooManyClusterRedirectionsException;
*/
public class JedisExceptionConverter implements Converter<Exception, DataAccessException> {
static final JedisExceptionConverter INSTANCE = new JedisExceptionConverter();
public DataAccessException convert(Exception ex) {
if (ex instanceof DataAccessException) {

View File

@@ -1,315 +0,0 @@
/*
* Copyright 2011-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.connection.jedis;
import redis.clients.jedis.BinaryJedisPubSub;
import redis.clients.jedis.ListPosition;
import redis.clients.jedis.Protocol;
import redis.clients.jedis.SortingParams;
import redis.clients.jedis.exceptions.JedisConnectionException;
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.exceptions.JedisException;
import redis.clients.jedis.util.SafeEncoder;
import java.io.IOException;
import java.io.StringReader;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeoutException;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.redis.RedisConnectionFailureException;
import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.connection.RedisListCommands.Position;
import org.springframework.data.redis.connection.ReturnType;
import org.springframework.data.redis.connection.SortParameters;
import org.springframework.data.redis.connection.SortParameters.Order;
import org.springframework.data.redis.connection.SortParameters.Range;
import org.springframework.data.redis.connection.zset.DefaultTuple;
import org.springframework.data.redis.connection.zset.Tuple;
import org.springframework.util.Assert;
/**
* Helper class featuring methods for Jedis connection handling, providing support for exception translation. Deprecated
* in favor of {@link JedisConverters}
*
* @author Costin Leau
* @author Jennifer Hickey
*/
@Deprecated
public abstract class JedisUtils {
private static final String OK_CODE = "OK";
private static final String OK_MULTI_CODE = "+OK";
private static final byte[] ONE = new byte[] { '1' };
private static final byte[] ZERO = new byte[] { '0' };
/**
* Converts the given, native Jedis exception to Spring's DAO hierarchy.
*
* @param ex Jedis exception
* @return converted exception
*/
public static DataAccessException convertJedisAccessException(JedisException ex) {
if (ex instanceof JedisDataException) {
return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
}
if (ex instanceof JedisConnectionException) {
return new RedisConnectionFailureException(ex.getMessage(), ex);
}
// fallback to invalid data exception
return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
}
/**
* Converts the given, native, runtime Jedis exception to Spring's DAO hierarchy.
*
* @param ex Jedis runtime/unchecked exception
* @return converted exception
*/
public static DataAccessException convertJedisAccessException(RuntimeException ex) {
if (ex instanceof JedisException) {
return convertJedisAccessException((JedisException) ex);
}
return null;
}
static DataAccessException convertJedisAccessException(IOException ex) {
if (ex instanceof UnknownHostException) {
return new RedisConnectionFailureException("Unknown host " + ex.getMessage(), ex);
}
return new RedisConnectionFailureException("Could not connect to Redis server", ex);
}
static DataAccessException convertJedisAccessException(TimeoutException ex) {
throw new RedisConnectionFailureException("Jedis pool timed out. Could not get Redis Connection", ex);
}
static boolean isStatusOk(String status) {
return status != null && (OK_CODE.equals(status) || OK_MULTI_CODE.equals(status));
}
/**
* Deprecated. Use #{@link JedisConverters#toBoolean(Long)}
*/
@Deprecated
static Boolean convertCodeReply(Number code) {
return (code != null ? code.intValue() == 1 : null);
}
/**
* Deprecated. Use #{@link JedisConverters#toTupleSet(Set)}
*/
@Deprecated
static Set<Tuple> convertJedisTuple(Set<redis.clients.jedis.Tuple> tuples) {
Set<Tuple> value = new LinkedHashSet<>(tuples.size());
for (redis.clients.jedis.Tuple tuple : tuples) {
value.add(new DefaultTuple(tuple.getBinaryElement(), tuple.getScore()));
}
return value;
}
static byte[][] convert(Map<byte[], byte[]> hgetAll) {
byte[][] result = new byte[hgetAll.size() * 2][];
int index = 0;
for (Map.Entry<byte[], byte[]> entry : hgetAll.entrySet()) {
result[index++] = entry.getKey();
result[index++] = entry.getValue();
}
return result;
}
/**
* Deprecated. Implement a method in {@link JedisConverters} instead
*/
@Deprecated
static Map<String, String> convert(String[] fields, String[] values) {
Map<String, String> result = new LinkedHashMap<>(fields.length);
for (int i = 0; i < values.length; i++) {
result.put(fields[i], values[i]);
}
return result;
}
/**
* Deprecated. Implement a method in {@link JedisConverters} instead
*/
@Deprecated
static String[] arrange(String[] keys, String[] values) {
String[] result = new String[keys.length * 2];
for (int i = 0; i < keys.length; i++) {
int index = i << 1;
result[index] = keys[i];
result[index + 1] = values[i];
}
return result;
}
static SortingParams convertSortParams(SortParameters params) {
SortingParams jedisParams = null;
if (params != null) {
jedisParams = new SortingParams();
byte[] byPattern = params.getByPattern();
if (byPattern != null) {
jedisParams.by(params.getByPattern());
}
byte[][] getPattern = params.getGetPattern();
if (getPattern != null) {
jedisParams.get(getPattern);
}
Range limit = params.getLimit();
if (limit != null) {
jedisParams.limit((int) limit.getStart(), (int) limit.getCount());
}
Order order = params.getOrder();
if (order != null && order.equals(Order.DESC)) {
jedisParams.desc();
}
Boolean isAlpha = params.isAlphabetic();
if (isAlpha != null && isAlpha) {
jedisParams.alpha();
}
}
return jedisParams;
}
/**
* Deprecated. Use #{@link JedisConverters#toBit(Boolean)}
*/
@Deprecated
static byte[] asBit(boolean value) {
return (value ? ONE : ZERO);
}
static ListPosition convertPosition(Position where) {
Assert.notNull(where, "list positions are mandatory");
return (Position.AFTER.equals(where) ? ListPosition.AFTER : ListPosition.BEFORE);
}
/**
* Deprecated. Use #{@link JedisConverters#toProperties(String)}
*/
@Deprecated
static Properties info(String string) {
Properties info = new Properties();
StringReader stringReader = new StringReader(string);
try {
info.load(stringReader);
} catch (Exception ex) {
throw new RedisSystemException("Cannot read Redis info", ex);
} finally {
stringReader.close();
}
return info;
}
static BinaryJedisPubSub adaptPubSub(MessageListener listener) {
return new JedisMessageListener(listener);
}
/**
* Deprecated. Use #{@link JedisConverters#toStrings(byte[][])}
*/
@Deprecated
static String[] convert(byte[]... raw) {
String[] result = new String[raw.length];
for (int i = 0; i < raw.length; i++) {
result[i] = SafeEncoder.encode(raw[i]);
}
return result;
}
static byte[][] bXPopArgs(int timeout, byte[]... keys) {
List<byte[]> args = new ArrayList<>();
for (byte[] arg : keys) {
args.add(arg);
}
args.add(Protocol.toByteArray(timeout));
return args.toArray(new byte[args.size()][]);
}
/**
* Deprecated. Use #{@link JedisConverters#toBytes(Integer)}
*/
@Deprecated
static byte[] asBytes(int number) {
return String.valueOf(number).getBytes();
}
/**
* Deprecated. Use #{@link JedisConverters#toString(byte[])}
*/
@Deprecated
static String asString(byte[] raw) {
return SafeEncoder.encode(raw);
}
@SuppressWarnings("unchecked")
static Object convertScriptReturn(ReturnType returnType, Object result) {
if (result instanceof String) {
// evalsha converts byte[] to String. Convert back for consistency
return SafeEncoder.encode((String) result);
}
if (returnType == ReturnType.STATUS) {
return JedisUtils.asString((byte[]) result);
}
if (returnType == ReturnType.BOOLEAN) {
// Lua false comes back as a null bulk reply
if (result == null) {
return Boolean.FALSE;
}
return ((Long) result == 1);
}
if (returnType == ReturnType.MULTI) {
List<Object> resultList = (List<Object>) result;
List<Object> convertedResults = new ArrayList<>();
for (Object res : resultList) {
if (res instanceof String) {
// evalsha converts byte[] to String. Convert back for consistency
convertedResults.add(SafeEncoder.encode((String) res));
} else {
convertedResults.add(res);
}
}
return convertedResults;
}
return result;
}
}

View File

@@ -1,96 +0,0 @@
/*
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.connection.jedis;
import redis.clients.jedis.Jedis;
import java.io.IOException;
import java.util.Properties;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.data.util.Version;
import org.springframework.util.StringUtils;
/**
* @author Christoph Strobl
* @since 1.3
*/
public class JedisVersionUtil {
private static Version jedisVersion = parseVersion(resolveJedisVersion());
/**
* @return current {@link redis.clients.jedis.Jedis} version.
*/
public static Version jedisVersion() {
return jedisVersion;
}
/**
* Parse version string {@literal eg. 1.1.1} to {@link Version}.
*
* @param version
* @return
*/
static Version parseVersion(String version) {
return Version.parse(version);
}
/**
* @return true if used jedis version is at minimum {@literal 2.4}.
*/
public static boolean atLeastJedis24() {
return atLeast("2.4");
}
private static String resolveJedisVersion() {
String version = Jedis.class.getPackage().getImplementationVersion();
if (!StringUtils.hasText(version)) {
try {
Properties props = PropertiesLoaderUtils.loadAllProperties("META-INF/maven/redis.clients/jedis/pom.properties");
if (props.containsKey("version")) {
version = props.getProperty("version");
}
} catch (IOException e) {
// ignore this one
}
}
return version;
}
/**
* Compares given version string against current jedis version.
*
* @param version
* @return true in case given version is greater than equal to current one.
*/
public static boolean atLeast(String version) {
return jedisVersion.compareTo(parseVersion(version)) >= 0;
}
/**
* Compares given version string against current jedis version.
*
* @param version
* @return true in case given version is less than equal to current one.
*/
public static boolean atMost(String version) {
return jedisVersion.compareTo(parseVersion(version)) <= 0;
}
}

View File

@@ -51,7 +51,6 @@ import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
import org.springframework.data.redis.connection.RedisZSetCommands.Range.Boundary;
import org.springframework.data.redis.connection.SortParameters.Order;
import org.springframework.data.redis.connection.convert.Converters;
import org.springframework.data.redis.connection.convert.LongToBooleanConverter;
import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter;
import org.springframework.data.redis.connection.zset.DefaultTuple;
import org.springframework.data.redis.connection.zset.Tuple;
@@ -124,12 +123,16 @@ public abstract class LettuceConverters extends Converters {
};
}
public static boolean toBoolean(long value) {
return value == 1;
}
/**
* @return
* @sice 1.3
*/
public static Converter<Long, Boolean> longToBooleanConverter() {
return LongToBooleanConverter.INSTANCE;
return Converters::toBoolean;
}
public static Long toLong(@Nullable Date source) {

View File

@@ -97,13 +97,13 @@ class LettuceReactiveClusterKeyCommands extends LettuceReactiveKeyCommands imple
return connection.execute(cmd -> Flux.from(commands).concatMap(command -> {
Assert.notNull(command.getKey(), "Key must not be null.");
Assert.notNull(command.getNewName(), "NewName must not be null!");
Assert.notNull(command.getNewKey(), "NewName must not be null!");
if (ClusterSlotHashUtil.isSameSlotForAllKeys(command.getKey(), command.getNewName())) {
if (ClusterSlotHashUtil.isSameSlotForAllKeys(command.getKey(), command.getNewKey())) {
return super.renameNX(Mono.just(command));
}
Mono<Boolean> result = cmd.exists(command.getNewName()).flatMap(exists -> {
Mono<Boolean> result = cmd.exists(command.getNewKey()).flatMap(exists -> {
if (exists == 1) {
return Mono.just(Boolean.FALSE);
@@ -112,8 +112,8 @@ class LettuceReactiveClusterKeyCommands extends LettuceReactiveKeyCommands imple
return cmd.dump(command.getKey())
.switchIfEmpty(Mono.error(new RedisSystemException("Cannot rename key that does not exist",
new RedisException("ERR no such key."))))
.flatMap(value -> cmd.restore(command.getNewName(), 0, value).flatMap(res -> cmd.del(command.getKey())))
.map(LettuceConverters.longToBooleanConverter()::convert);
.flatMap(value -> cmd.restore(command.getNewKey(), 0, value).flatMap(res -> cmd.del(command.getKey())))
.map(LettuceConverters::toBoolean);
});
return result.map(val -> new BooleanResponse<>(command, val));

View File

@@ -142,9 +142,9 @@ class LettuceReactiveKeyCommands implements ReactiveKeyCommands {
return connection.execute(cmd -> Flux.from(commands).concatMap(command -> {
Assert.notNull(command.getKey(), "Key must not be null!");
Assert.notNull(command.getNewName(), "New name must not be null!");
Assert.notNull(command.getNewKey(), "New name must not be null!");
return cmd.rename(command.getKey(), command.getNewName()).map(LettuceConverters::stringToBoolean)
return cmd.rename(command.getKey(), command.getNewKey()).map(LettuceConverters::stringToBoolean)
.map(value -> new BooleanResponse<>(command, value));
}));
}
@@ -155,9 +155,9 @@ class LettuceReactiveKeyCommands implements ReactiveKeyCommands {
return connection.execute(cmd -> Flux.from(commands).concatMap(command -> {
Assert.notNull(command.getKey(), "Key must not be null!");
Assert.notNull(command.getNewName(), "New name must not be null!");
Assert.notNull(command.getNewKey(), "New name must not be null!");
return cmd.renamenx(command.getKey(), command.getNewName()).map(value -> new BooleanResponse<>(command, value));
return cmd.renamenx(command.getKey(), command.getNewKey()).map(value -> new BooleanResponse<>(command, value));
}));
}

View File

@@ -191,7 +191,7 @@ abstract class AbstractOperations<K, V> {
byte[][] rawKeys = new byte[2][];
rawKeys[0] = rawKey(key);
rawKeys[1] = rawKey(key);
rawKeys[1] = rawKey(otherKey);
return rawKeys;
}

View File

@@ -52,21 +52,6 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
@Nullable
Long add(Point point, M member);
/**
* Add {@link Point} with given member {@literal name} to {@literal key}.
*
* @param point must not be {@literal null}.
* @param member must not be {@literal null}.
* @return Number of elements added. {@literal null} when used in pipeline / transaction.
* @see <a href="https://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
* @deprecated since 2.0, use {@link #add(Point, Object)}.
*/
@Deprecated
@Nullable
default Long geoAdd(Point point, M member) {
return add(point, member);
}
/**
* Add {@link GeoLocation} to {@literal key}.
*
@@ -78,20 +63,6 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
@Nullable
Long add(GeoLocation<M> location);
/**
* Add {@link GeoLocation} to {@literal key}.
*
* @param location must not be {@literal null}.
* @return Number of elements added. {@literal null} when used in pipeline / transaction.
* @see <a href="https://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
* @deprecated since 2.0, use {@link #add(GeoLocation)}.
*/
@Deprecated
@Nullable
default Long geoAdd(GeoLocation<M> location) {
return add(location);
}
/**
* Add {@link Map} of member / {@link Point} pairs to {@literal key}.
*
@@ -103,20 +74,6 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
@Nullable
Long add(Map<M, Point> memberCoordinateMap);
/**
* Add {@link Map} of member / {@link Point} pairs to {@literal key}.
*
* @param memberCoordinateMap must not be {@literal null}.
* @return Number of elements added. {@literal null} when used in pipeline / transaction.
* @see <a href="https://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
* @deprecated since 2.0, use {@link #add(Map)}.
*/
@Deprecated
@Nullable
default Long geoAdd(Map<M, Point> memberCoordinateMap) {
return add(memberCoordinateMap);
}
/**
* Add {@link GeoLocation}s to {@literal key}
*
@@ -128,20 +85,6 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
@Nullable
Long add(Iterable<GeoLocation<M>> locations);
/**
* Add {@link GeoLocation}s to {@literal key}
*
* @param locations must not be {@literal null}.
* @return Number of elements added. {@literal null} when used in pipeline / transaction.
* @see <a href="https://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
* @deprecated since 2.0, use {@link #add(Iterable)}.
*/
@Deprecated
@Nullable
default Long geoAdd(Iterable<GeoLocation<M>> locations) {
return add(locations);
}
/**
* Get the {@link Distance} between {@literal member1} and {@literal member2}.
*
@@ -154,21 +97,6 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
@Nullable
Distance distance(M member1, M member2);
/**
* Get the {@link Distance} between {@literal member1} and {@literal member2}.
*
* @param member1 must not be {@literal null}.
* @param member2 must not be {@literal null}.
* @return can be {@literal null}.
* @see <a href="https://redis.io/commands/geodist">Redis Documentation: GEODIST</a>
* @deprecated since 2.0, use {@link #distance(Object, Object)}.
*/
@Deprecated
@Nullable
default Distance geoDist(M member1, M member2) {
return distance(member1, member2);
}
/**
* Get the {@link Distance} between {@literal member1} and {@literal member2} in the given {@link Metric}.
*
@@ -182,22 +110,6 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
@Nullable
Distance distance(M member1, M member2, Metric metric);
/**
* Get the {@link Distance} between {@literal member1} and {@literal member2} in the given {@link Metric}.
*
* @param member1 must not be {@literal null}.
* @param member2 must not be {@literal null}.
* @param metric must not be {@literal null}.
* @return can be {@literal null}.
* @see <a href="https://redis.io/commands/geodist">Redis Documentation: GEODIST</a>
* @deprecated since 2.0, use {@link #distance(Object, Object, Metric)}.
*/
@Deprecated
@Nullable
default Distance geoDist(M member1, M member2, Metric metric) {
return distance(member1, member2, metric);
}
/**
* Get Geohash representation of the position for one or more {@literal member}s.
*
@@ -209,20 +121,6 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
@Nullable
List<String> hash(M... members);
/**
* Get Geohash representation of the position for one or more {@literal member}s.
*
* @param members must not be {@literal null}.
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/geohash">Redis Documentation: GEOHASH</a>
* @deprecated since 2.0, use {@link #hash(Object[])}.
*/
@Deprecated
@Nullable
default List<String> geoHash(M... members) {
return hash(members);
}
/**
* Get the {@link Point} representation of positions for one or more {@literal member}s.
*
@@ -234,19 +132,6 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
@Nullable
List<Point> position(M... members);
/**
* Get the {@link Point} representation of positions for one or more {@literal member}s.
*
* @param members must not be {@literal null}.
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/geopos">Redis Documentation: GEOPOS</a>
* @deprecated since 2.0, use {@link #position(Object[])}.
*/
@Deprecated
@Nullable
default List<Point> geoPos(M... members) {
return position(members);
}
/**
* Get the {@literal member}s within the boundaries of a given {@link Circle}.
@@ -259,20 +144,6 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
@Nullable
GeoResults<GeoLocation<M>> radius(Circle within);
/**
* Get the {@literal member}s within the boundaries of a given {@link Circle}.
*
* @param within must not be {@literal null}.
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/georadius">Redis Documentation: GEORADIUS</a>
* @deprecated since 2.0, use {@link #radius(Circle)}.
*/
@Deprecated
@Nullable
default GeoResults<GeoLocation<M>> geoRadius(Circle within) {
return radius(within);
}
/**
* Get the {@literal member}s within the boundaries of a given {@link Circle} applying {@link GeoRadiusCommandArgs}.
*
@@ -285,23 +156,6 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
@Nullable
GeoResults<GeoLocation<M>> radius(Circle within, GeoRadiusCommandArgs args);
/**
* Get the {@literal member}s within the boundaries of a given {@link Circle} applying {@link GeoRadiusCommandArgs}.
*
* @param within must not be {@literal null}.
* @param args must not be {@literal null}.
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/georadius">Redis Documentation: GEORADIUS</a>
* @deprecated since 2.0, use {@link #radius(Circle, GeoRadiusCommandArgs)}.
*/
@Deprecated
@Nullable
default GeoResults<GeoLocation<M>> geoRadius(Circle within, GeoRadiusCommandArgs args) {
return radius(within, args);
}
// TODO: Bound ops should not accept K key
/**
* Get the {@literal member}s within the circle defined by the {@literal members} coordinates and given
* {@literal radius}.
@@ -313,23 +167,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
* @see <a href="https://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
*/
@Nullable
GeoResults<GeoLocation<M>> radius(K key, M member, double radius);
/**
* Get the {@literal member}s within the circle defined by the {@literal members} coordinates and given
* {@literal radius}.
*
* @param member must not be {@literal null}.
* @param radius
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
* @deprecated since 2.0, use {@link #radius(Object, Object, double)}.
*/
@Deprecated
@Nullable
default GeoResults<GeoLocation<M>> geoRadiusByMember(K key, M member, double radius) {
return radius(key, member, radius);
}
GeoResults<GeoLocation<M>> radius(M member, double radius);
/**
* Get the {@literal member}s within the circle defined by the {@literal members} coordinates and given
@@ -344,22 +182,6 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
@Nullable
GeoResults<GeoLocation<M>> radius(M member, Distance distance);
/**
* Get the {@literal member}s within the circle defined by the {@literal members} coordinates and given
* {@literal radius} applying {@link Metric}.
*
* @param member must not be {@literal null}.
* @param distance must not be {@literal null}.
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
* @deprecated since 2.0, use {@link #radius(Object, Distance)}.
*/
@Deprecated
@Nullable
default GeoResults<GeoLocation<M>> geoRadiusByMember(M member, Distance distance) {
return radius(member, distance);
}
/**
* Get the {@literal member}s within the circle defined by the {@literal members} coordinates and given
* {@literal radius} applying {@link Metric} and {@link GeoRadiusCommandArgs}.
@@ -374,23 +196,6 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
@Nullable
GeoResults<GeoLocation<M>> radius(M member, Distance distance, GeoRadiusCommandArgs args);
/**
* Get the {@literal member}s within the circle defined by the {@literal members} coordinates and given
* {@literal radius} applying {@link Metric} and {@link GeoRadiusCommandArgs}.
*
* @param member must not be {@literal null}.
* @param distance must not be {@literal null}.
* @param args must not be {@literal null}.
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
* @deprecated since 2.0, use {@link #radius(Object, Distance, GeoRadiusCommandArgs)}.
*/
@Deprecated
@Nullable
default GeoResults<GeoLocation<M>> geoRadiusByMember(M member, Distance distance, GeoRadiusCommandArgs args) {
return radius(member, distance, args);
}
/**
* Remove the {@literal member}s.
*
@@ -401,19 +206,6 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
@Nullable
Long remove(M... members);
/**
* Remove the {@literal member}s.
*
* @param members must not be {@literal null}.
* @return Number of elements removed. {@literal null} when used in pipeline / transaction.
* @deprecated since 2.0, use {@link #remove(Object[])}.
*/
@Deprecated
@Nullable
default Long geoRemove(M... members) {
return remove(members);
}
/**
* Get the {@literal member}s within the boundaries of a given {@link Circle}.
*

View File

@@ -31,8 +31,8 @@ import org.springframework.util.Assert;
*/
public class ConvertingCursor<S, T> implements Cursor<T> {
private Cursor<S> delegate;
private Converter<S, T> converter;
private final Cursor<S> delegate;
private final Converter<S, T> converter;
/**
* @param cursor Cursor must not be {@literal null}.
@@ -77,12 +77,6 @@ public class ConvertingCursor<S, T> implements Cursor<T> {
return delegate.isClosed();
}
@Override
public Cursor<T> open() {
this.delegate = delegate.open();
return this;
}
@Override
public long getPosition() {
return delegate.getPosition();

View File

@@ -48,16 +48,6 @@ public interface Cursor<T> extends CloseableIterator<T> {
*/
boolean isClosed();
/**
* Opens cursor and returns itself. This method is intended to be called by components constructing a {@link Cursor}
* and should not be called externally.
*
* @return the opened cursor.
* @deprecated to be removed from the interface in the next major version.
*/
@Deprecated
Cursor<T> open();
/**
* @return the current position of the cursor.
*/

View File

@@ -105,7 +105,7 @@ class DefaultBoundGeoOperations<K, M> extends DefaultBoundKeyOperations<K> imple
}
@Override
public GeoResults<GeoLocation<M>> radius(K key, M member, double radius) {
public GeoResults<GeoLocation<M>> radius(M member, double radius) {
return ops.radius(getKey(), member, radius);
}

View File

@@ -56,22 +56,6 @@ public interface GeoOperations<K, M> {
@Nullable
Long add(K key, Point point, M member);
/**
* Add {@link Point} with given member {@literal name} to {@literal key}.
*
* @param key must not be {@literal null}.
* @param point must not be {@literal null}.
* @param member must not be {@literal null}.
* @return Number of elements added. {@literal null} when used in pipeline / transaction.
* @see <a href="https://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
* @deprecated since 2.0, use {@link #add(Object, Point, Object)}.
*/
@Deprecated
@Nullable
default Long geoAdd(K key, Point point, M member) {
return add(key, point, member);
}
/**
* Add {@link GeoLocation} to {@literal key}.
*
@@ -84,21 +68,6 @@ public interface GeoOperations<K, M> {
@Nullable
Long add(K key, GeoLocation<M> location);
/**
* Add {@link GeoLocation} to {@literal key}.
*
* @param key must not be {@literal null}.
* @param location must not be {@literal null}.
* @return Number of elements added. {@literal null} when used in pipeline / transaction.
* @see <a href="https://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
* @deprecated since 2.0, use {@link #add(Object, GeoLocation)}.
*/
@Deprecated
@Nullable
default Long geoAdd(K key, GeoLocation<M> location) {
return add(key, location);
}
/**
* Add {@link Map} of member / {@link Point} pairs to {@literal key}.
*
@@ -111,21 +80,6 @@ public interface GeoOperations<K, M> {
@Nullable
Long add(K key, Map<M, Point> memberCoordinateMap);
/**
* Add {@link Map} of member / {@link Point} pairs to {@literal key}.
*
* @param key must not be {@literal null}.
* @param memberCoordinateMap must not be {@literal null}.
* @return Number of elements added. {@literal null} when used in pipeline / transaction.
* @see <a href="https://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
* @deprecated since 2.0, use {@link #add(Object, Map)}.
*/
@Deprecated
@Nullable
default Long geoAdd(K key, Map<M, Point> memberCoordinateMap) {
return add(key, memberCoordinateMap);
}
/**
* Add {@link GeoLocation}s to {@literal key}
*
@@ -138,21 +92,6 @@ public interface GeoOperations<K, M> {
@Nullable
Long add(K key, Iterable<GeoLocation<M>> locations);
/**
* Add {@link GeoLocation}s to {@literal key}
*
* @param key must not be {@literal null}.
* @param locations must not be {@literal null}.
* @return Number of elements added. {@literal null} when used in pipeline / transaction.
* @see <a href="https://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
* @deprecated since 2.0, use {@link #add(Object, Iterable)}.
*/
@Deprecated
@Nullable
default Long geoAdd(K key, Iterable<GeoLocation<M>> locations) {
return add(key, locations);
}
/**
* Get the {@link Distance} between {@literal member1} and {@literal member2}.
*
@@ -166,22 +105,6 @@ public interface GeoOperations<K, M> {
@Nullable
Distance distance(K key, M member1, M member2);
/**
* Get the {@link Distance} between {@literal member1} and {@literal member2}.
*
* @param key must not be {@literal null}.
* @param member1 must not be {@literal null}.
* @param member2 must not be {@literal null}.
* @return can be {@literal null}.
* @see <a href="https://redis.io/commands/geodist">Redis Documentation: GEODIST</a>
* @deprecated since 2.0, use {@link #distance(Object, Object, Object)}.
*/
@Deprecated
@Nullable
default Distance geoDist(K key, M member1, M member2) {
return distance(key, member1, member2);
}
/**
* Get the {@link Distance} between {@literal member1} and {@literal member2} in the given {@link Metric}.
*
@@ -196,23 +119,6 @@ public interface GeoOperations<K, M> {
@Nullable
Distance distance(K key, M member1, M member2, Metric metric);
/**
* Get the {@link Distance} between {@literal member1} and {@literal member2} in the given {@link Metric}.
*
* @param key must not be {@literal null}.
* @param member1 must not be {@literal null}.
* @param member2 must not be {@literal null}.
* @param metric must not be {@literal null}.
* @return can be {@literal null}.
* @see <a href="https://redis.io/commands/geodist">Redis Documentation: GEODIST</a>
* @deprecated since 2.0, use {@link #distance(Object, Object, Object, Metric)}.
*/
@Deprecated
@Nullable
default Distance geoDist(K key, M member1, M member2, Metric metric) {
return distance(key, member1, member2, metric);
}
/**
* Get Geohash representation of the position for one or more {@literal member}s.
*
@@ -225,21 +131,6 @@ public interface GeoOperations<K, M> {
@Nullable
List<String> hash(K key, M... members);
/**
* Get Geohash representation of the position for one or more {@literal member}s.
*
* @param key must not be {@literal null}.
* @param members must not be {@literal null}.
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/geohash">Redis Documentation: GEOHASH</a>
* @deprecated since 2.0, use {@link #hash(Object, Object[])}.
*/
@Deprecated
@Nullable
default List<String> geoHash(K key, M... members) {
return hash(key, members);
}
/**
* Get the {@link Point} representation of positions for one or more {@literal member}s.
*
@@ -252,21 +143,6 @@ public interface GeoOperations<K, M> {
@Nullable
List<Point> position(K key, M... members);
/**
* Get the {@link Point} representation of positions for one or more {@literal member}s.
*
* @param key must not be {@literal null}.
* @param members must not be {@literal null}.
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/geopos">Redis Documentation: GEOPOS</a>
* @deprecated since 2.0, use {@link #position(Object, Object[])}.
*/
@Deprecated
@Nullable
default List<Point> geoPos(K key, M... members) {
return position(key, members);
}
/**
* Get the {@literal member}s within the boundaries of a given {@link Circle}.
*
@@ -279,21 +155,6 @@ public interface GeoOperations<K, M> {
@Nullable
GeoResults<GeoLocation<M>> radius(K key, Circle within);
/**
* Get the {@literal member}s within the boundaries of a given {@link Circle}.
*
* @param key must not be {@literal null}.
* @param within must not be {@literal null}.
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/georadius">Redis Documentation: GEORADIUS</a>
* @deprecated since 2.0, use {@link #radius(Object, Circle)}.
*/
@Deprecated
@Nullable
default GeoResults<GeoLocation<M>> geoRadius(K key, Circle within) {
return radius(key, within);
}
/**
* Get the {@literal member}s within the boundaries of a given {@link Circle} applying {@link GeoRadiusCommandArgs}.
*
@@ -307,22 +168,6 @@ public interface GeoOperations<K, M> {
@Nullable
GeoResults<GeoLocation<M>> radius(K key, Circle within, GeoRadiusCommandArgs args);
/**
* Get the {@literal member}s within the boundaries of a given {@link Circle} applying {@link GeoRadiusCommandArgs}.
*
* @param key must not be {@literal null}.
* @param within must not be {@literal null}.
* @param args must not be {@literal null}.
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/georadius">Redis Documentation: GEORADIUS</a>
* @deprecated since 2.0, use {@link #radius(Object, Circle, GeoRadiusCommandArgs)}.
*/
@Deprecated
@Nullable
default GeoResults<GeoLocation<M>> geoRadius(K key, Circle within, GeoRadiusCommandArgs args) {
return radius(key, within, args);
}
/**
* Get the {@literal member}s within the circle defined by the {@literal members} coordinates and given
* {@literal radius}.
@@ -337,23 +182,6 @@ public interface GeoOperations<K, M> {
@Nullable
GeoResults<GeoLocation<M>> radius(K key, M member, double radius);
/**
* Get the {@literal member}s within the circle defined by the {@literal members} coordinates and given
* {@literal radius}.
*
* @param key must not be {@literal null}.
* @param member must not be {@literal null}.
* @param radius
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
* @deprecated since 2.0, use {@link #radius(Object, Object, double)}.
*/
@Deprecated
@Nullable
default GeoResults<GeoLocation<M>> geoRadiusByMember(K key, M member, double radius) {
return radius(key, member, radius);
}
/**
* Get the {@literal member}s within the circle defined by the {@literal members} coordinates and given
* {@literal radius} applying {@link Metric}.
@@ -368,23 +196,6 @@ public interface GeoOperations<K, M> {
@Nullable
GeoResults<GeoLocation<M>> radius(K key, M member, Distance distance);
/**
* Get the {@literal member}s within the circle defined by the {@literal members} coordinates and given
* {@literal radius} applying {@link Metric}.
*
* @param key must not be {@literal null}.
* @param member must not be {@literal null}.
* @param distance must not be {@literal null}.
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
* @deprecated since 2.0, use {@link #radius(Object, Object, Distance)}.
*/
@Deprecated
@Nullable
default GeoResults<GeoLocation<M>> geoRadiusByMember(K key, M member, Distance distance) {
return radius(key, member, distance);
}
/**
* Get the {@literal member}s within the circle defined by the {@literal members} coordinates and given
* {@literal radius} applying {@link Metric} and {@link GeoRadiusCommandArgs}.
@@ -400,24 +211,6 @@ public interface GeoOperations<K, M> {
@Nullable
GeoResults<GeoLocation<M>> radius(K key, M member, Distance distance, GeoRadiusCommandArgs args);
/**
* Get the {@literal member}s within the circle defined by the {@literal members} coordinates and given
* {@literal radius} applying {@link Metric} and {@link GeoRadiusCommandArgs}.
*
* @param key must not be {@literal null}.
* @param member must not be {@literal null}.
* @param distance must not be {@literal null}.
* @param args must not be {@literal null}.
* @return never {@literal null} unless used in pipeline / transaction.
* @see <a href="https://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
* @deprecated since 2.0, use {@link #radius(Object, Object, Distance, GeoRadiusCommandArgs)}.
*/
@Deprecated
@Nullable
default GeoResults<GeoLocation<M>> geoRadiusByMember(K key, M member, Distance distance, GeoRadiusCommandArgs args) {
return radius(key, member, distance, args);
}
/**
* Remove the {@literal member}s.
*
@@ -429,20 +222,6 @@ public interface GeoOperations<K, M> {
@Nullable
Long remove(K key, M... members);
/**
* Remove the {@literal member}s.
*
* @param key must not be {@literal null}.
* @param members must not be {@literal null}.
* @return Number of elements removed. {@literal null} when used in pipeline / transaction.
* @deprecated since 2.0, use {@link #remove(Object, Object[])}.
*/
@Deprecated
@Nullable
default Long geoRemove(K key, M... members) {
return remove(key, members);
}
/**
* Get the {@literal member}s within the boundaries of a given {@link Circle}.
*

View File

@@ -141,8 +141,6 @@ public enum RedisCommand {
// -- R
RANDOMKEY("r", 0, 0), //
@Deprecated
RANAME("w", 2, 2), //
RENAME("w", 2, 2), //
RENAMENX("w", 2, 2), //
REPLICAOF("w", 2), //

View File

@@ -267,22 +267,6 @@ public abstract class RedisConnectionUtils {
doCloseConnection(conn);
}
/**
* Closes the given {@link RedisConnection}, created via the given factory if not managed externally (i.e. not bound
* to the transaction).
*
* @param conn the Redis connection to close.
* @param factory the Redis factory that the connection was created with.
* @param transactionSupport whether transaction support is enabled.
* @since 2.1.9
* @deprecated since 2.4.2, use {@link #releaseConnection(RedisConnection, RedisConnectionFactory)}
*/
@Deprecated
public static void releaseConnection(@Nullable RedisConnection conn, RedisConnectionFactory factory,
boolean transactionSupport) {
releaseConnection(conn, factory);
}
/**
* Determine whether the given two RedisConnections are equal, asking the target {@link RedisConnection} in case of a
* proxy. Used to detect equality even if the user passed in a raw target Connection while the held one is a proxy.

View File

@@ -44,7 +44,6 @@ import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.PartialUpdate.PropertyUpdate;
import org.springframework.data.redis.core.PartialUpdate.UpdateCommand;
import org.springframework.data.redis.core.RedisKeyValueAdapter.RedisUpdateObject.Index;
import org.springframework.data.redis.core.convert.CustomConversions;
import org.springframework.data.redis.core.convert.GeoIndexedPropertyValue;
import org.springframework.data.redis.core.convert.KeyspaceConfiguration;
import org.springframework.data.redis.core.convert.MappingRedisConverter;
@@ -140,21 +139,6 @@ public class RedisKeyValueAdapter extends AbstractKeyValueAdapter
this(redisOps, mappingContext, new RedisCustomConversions());
}
/**
* Creates new {@link RedisKeyValueAdapter}.
*
* @param redisOps must not be {@literal null}.
* @param mappingContext must not be {@literal null}.
* @param customConversions can be {@literal null}.
* @deprecated since 2.0, use
* {@link #RedisKeyValueAdapter(RedisOperations, RedisMappingContext, org.springframework.data.convert.CustomConversions)}.
*/
@Deprecated
public RedisKeyValueAdapter(RedisOperations<?, ?> redisOps, RedisMappingContext mappingContext,
CustomConversions customConversions) {
this(redisOps, mappingContext, (org.springframework.data.convert.CustomConversions) customConversions);
}
/**
* Creates new {@link RedisKeyValueAdapter}.
*

View File

@@ -222,7 +222,7 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
return postProcessResult(result, connToUse, existingConnection);
} finally {
RedisConnectionUtils.releaseConnection(conn, factory, enableTransactionSupport);
RedisConnectionUtils.releaseConnection(conn, factory);
}
}

View File

@@ -1,47 +0,0 @@
/*
* Copyright 2011-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.core.convert;
import java.util.List;
/**
* Value object to capture custom conversion. That is essentially a {@link List} of converters and some additional logic
* around them.
*
* @author Olivyer Gierke
* @author Thomas Darimont
* @author Christoph Strobl
* @author Mark Paluch
* @since 1.7
* @deprecated since 2.0, use {@link RedisCustomConversions}.
*/
@Deprecated
public class CustomConversions extends RedisCustomConversions {
/**
* Creates an empty {@link CustomConversions} object.
*/
public CustomConversions() {}
/**
* Creates a new {@link CustomConversions} instance registering the given converters.
*
* @param converters
*/
public CustomConversions(List<?> converters) {
super(converters);
}
}

View File

@@ -1195,12 +1195,6 @@ public class MappingRedisConverter implements RedisConverter, InitializingBean {
public static final String DELIMITER = ":";
public static final String PHANTOM_SUFFIX = DELIMITER + PHANTOM;
/**
* @deprecated since 2.6. Please use {@link #DELIMITER} instead.
*/
@Deprecated(/* since="2.6" */)
public static final String DELIMITTER = DELIMITER;
private final String keyspace;
private final String id;
private final boolean phantomKey;
@@ -1281,12 +1275,6 @@ public class MappingRedisConverter implements RedisConverter, InitializingBean {
public static final byte DELIMITER = ':';
public static final byte[] PHANTOM_SUFFIX = ByteUtils.concat(new byte[] { DELIMITER }, PHANTOM);
/**
* @deprecated since 2.6. Please use {@link #DELIMITER} instead.
*/
@Deprecated(/* since="2.6" */)
public static final byte DELIMITTER = DELIMITER;
private final byte[] keyspace;
private final byte[] id;
private final boolean phantomKey;

View File

@@ -19,7 +19,7 @@ import java.util.Collections;
import java.util.Map;
import java.util.Set;
import org.springframework.data.redis.core.convert.CustomConversions;
import org.springframework.data.convert.CustomConversions;
import org.springframework.data.redis.core.convert.IndexResolver;
import org.springframework.data.redis.core.convert.IndexedData;
import org.springframework.data.redis.core.convert.MappingRedisConverter;
@@ -95,24 +95,13 @@ public class ObjectHashMapper implements HashMapper<Object, byte[], byte[]> {
this.converter = converter;
}
/**
* Creates new {@link ObjectHashMapper}.
*
* @param customConversions can be {@literal null}.
* @deprecated since 2.0, use {@link #ObjectHashMapper(org.springframework.data.convert.CustomConversions)}.
*/
@Deprecated
public ObjectHashMapper(CustomConversions customConversions) {
this((org.springframework.data.convert.CustomConversions) customConversions);
}
/**
* Creates new {@link ObjectHashMapper}.
*
* @param customConversions can be {@literal null}.
* @since 2.0
*/
public ObjectHashMapper(@Nullable org.springframework.data.convert.CustomConversions customConversions) {
public ObjectHashMapper(@Nullable CustomConversions customConversions) {
MappingRedisConverter mappingConverter = new MappingRedisConverter(new RedisMappingContext(),
new NoOpIndexResolver(), new NoOpReferenceResolver());

View File

@@ -316,15 +316,6 @@ public interface StreamMessageListenerContainer<K, V extends Record<K, ?>> exten
return consumer;
}
/**
* @return
* @deprecated since 2.3, use {@link #isAutoAcknowledge()} for improved readability instead.
*/
@Deprecated
public boolean isAutoAck() {
return isAutoAcknowledge();
}
/**
* @return
* @since 2.3
@@ -453,19 +444,6 @@ public interface StreamMessageListenerContainer<K, V extends Record<K, ?>> exten
return this;
}
/**
* Configure auto-acknowledgement for stream message consumption.
*
* @param autoAck {@literal true} (default) to auto-acknowledge received messages or {@literal false} for external
* acknowledgement.
* @return {@code this} {@link ConsumerStreamReadRequestBuilder}.
* @deprecated since 2.3, use {@link #autoAcknowledge(boolean)} instead.
*/
@Deprecated
public ConsumerStreamReadRequestBuilder<K> autoAck(boolean autoAck) {
return autoAcknowledge(autoAck);
}
/**
* Configure auto-acknowledgement for stream message consumption. This method is an alias for
* {@link #autoAck(boolean)} for improved readability.