diff --git a/src/main/java/org/springframework/data/redis/cache/RedisCache.java b/src/main/java/org/springframework/data/redis/cache/RedisCache.java index f6877da44..5c7193b52 100644 --- a/src/main/java/org/springframework/data/redis/cache/RedisCache.java +++ b/src/main/java/org/springframework/data/redis/cache/RedisCache.java @@ -41,7 +41,7 @@ import org.springframework.util.ReflectionUtils; /** * {@link org.springframework.cache.Cache} implementation using for Redis as the underlying store for cache data. - * + *
* Use {@link RedisCacheManager} to create {@link RedisCache} instances.
*
* @author Christoph Strobl
@@ -52,6 +52,7 @@ import org.springframework.util.ReflectionUtils;
* @see org.springframework.cache.support.AbstractValueAdaptingCache
* @since 2.0
*/
+@SuppressWarnings("unused")
public class RedisCache extends AbstractValueAdaptingCache {
private static final byte[] BINARY_NULL_VALUE = RedisSerializer.java().serialize(NullValue.INSTANCE);
@@ -136,7 +137,8 @@ public class RedisCache extends AbstractValueAdaptingCache {
}
@SuppressWarnings("unchecked")
- private synchronized @Nullable
* Start with {@link RedisCacheConfiguration#defaultCacheConfig()} and customize {@link RedisCache} behaviour
* from that point on.
*
@@ -344,9 +344,9 @@ public class RedisCacheConfiguration {
/**
* Registers default cache {@link Converter key converters}.
- *
+ *
* The following converters get registered:
- *
+ *
*
+ * The command is executed as is, with as little interpretation as possible - it is up to the caller to take care
+ * of any processing of arguments or the result.
*
- * @param command Command to execute. must not be {@literal null}.
- * @param args Possible command arguments (may be empty).
- * @return execution result. Can be {@literal null}.
+ * @param command Redis {@link String command} to execute; must not be {@literal null}.
+ * @param args optional array of command arguments; may be empty;
+ * @return the execution result; may be {@literal null}.
*/
@Nullable
Object execute(String command, byte[]... args);
+
}
diff --git a/src/main/java/org/springframework/data/redis/core/RedisCallback.java b/src/main/java/org/springframework/data/redis/core/RedisCallback.java
index da1f8387c..1faadc0c4 100644
--- a/src/main/java/org/springframework/data/redis/core/RedisCallback.java
+++ b/src/main/java/org/springframework/data/redis/core/RedisCallback.java
@@ -25,17 +25,22 @@ import org.springframework.lang.Nullable;
* {@code get/set/trim etc...}.
*
* @author Costin Leau
+ * @author John Blum
*/
public interface RedisCallback
+ * Callback code need not care about activating/opening or closing the {@link RedisConnection},
+ * nor handling {@link Exception exceptions}.
*
- * @param connection active Redis connection
- * @return a result object or {@code null} if none
- * @throws DataAccessException
+ * @param connection active {@link RedisConnection Redis connection}.
+ * @return the {@link Object result} of the operation performed in the callback or {@code null}.
+ * @throws DataAccessException if the operation performed by the callback fails to execute in the context of Redis
+ * using the given {@link RedisConnection}.
*/
@Nullable
T doInRedis(RedisConnection connection) throws DataAccessException;
+
}
diff --git a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java
index a343ab4af..b6b12293e 100644
--- a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java
+++ b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java
@@ -131,6 +131,18 @@ public abstract class AbstractConnectionIntegrationTests {
protected RedisConnection byteConnection;
+ private boolean isJedisOrLettuceConnection(RedisConnectionFactory connectionFactory) {
+ return ConnectionUtils.isJedis(connectionFactory) || ConnectionUtils.isLettuce(connectionFactory);
+ }
+
+ private boolean isNotJedisOrLettuceConnection(RedisConnectionFactory connectionFactory) {
+ return !isJedisOrLettuceConnection(connectionFactory);
+ }
+
+ private boolean isPipelinedOrQueueingConnection(RedisConnection connection) {
+ return connection.isPipelined() || connection.isQueueing();
+ }
+
@BeforeEach
public void setUp() {
@@ -2595,12 +2607,12 @@ public abstract class AbstractConnectionIntegrationTests {
@Test // DATAREDIS-290
void scanShouldReadEntireValueRange() {
- if (!ConnectionUtils.isJedis(connectionFactory) && !ConnectionUtils.isLettuce(connectionFactory)) {
+ if (isNotJedisOrLettuceConnection(connectionFactory)) {
throw new AssumptionViolatedException("SCAN is only available for jedis and lettuce");
}
- if (connection.isPipelined() || connection.isQueueing()) {
- throw new AssumptionViolatedException("SCAN is only available in non pipeline | queue mode");
+ if (isPipelinedOrQueueingConnection(connection)) {
+ throw new AssumptionViolatedException("SCAN is only available in non-pipeline | non-queueing mode");
}
connection.set("spring", "data");
@@ -2626,8 +2638,9 @@ public abstract class AbstractConnectionIntegrationTests {
@EnabledOnRedisVersion("6.0")
void scanWithType() {
- assumeThat(connection.isPipelined() || connection.isQueueing())
- .describedAs("SCAN is only available in non pipeline | queue mode").isFalse();
+ assumeThat(isPipelinedOrQueueingConnection(connection))
+ .describedAs("SCAN is only available in non-pipeline | non-queueing mode")
+ .isFalse();
connection.set("key", "data");
connection.lPush("list", "foo");
@@ -2670,11 +2683,11 @@ public abstract class AbstractConnectionIntegrationTests {
@Test // DATAREDIS-306
void zScanShouldReadEntireValueRange() {
- if (!ConnectionUtils.isJedis(connectionFactory) && !ConnectionUtils.isLettuce(connectionFactory)) {
+ if (isNotJedisOrLettuceConnection(connectionFactory)) {
throw new AssumptionViolatedException("ZSCAN is only available for jedis and lettuce");
}
- if (connection.isPipelined() || connection.isQueueing()) {
+ if (isPipelinedOrQueueingConnection(connection)) {
throw new AssumptionViolatedException("ZSCAN is only available in non pipeline | queue mode");
}
@@ -2701,11 +2714,11 @@ public abstract class AbstractConnectionIntegrationTests {
@Test // DATAREDIS-304
void sScanShouldReadEntireValueRange() {
- if (!ConnectionUtils.isJedis(connectionFactory) && !ConnectionUtils.isLettuce(connectionFactory)) {
+ if (isNotJedisOrLettuceConnection(connectionFactory)) {
throw new AssumptionViolatedException("SCAN is only available for jedis and lettuce");
}
- if (connection.isPipelined() || connection.isQueueing()) {
+ if (isPipelinedOrQueueingConnection(connection)) {
throw new AssumptionViolatedException("SCAN is only available in non pipeline | queue mode");
}
@@ -2726,11 +2739,11 @@ public abstract class AbstractConnectionIntegrationTests {
@Test // DATAREDIS-305
void hScanShouldReadEntireValueRange() {
- if (!ConnectionUtils.isJedis(connectionFactory) && !ConnectionUtils.isLettuce(connectionFactory)) {
+ if (isNotJedisOrLettuceConnection(connectionFactory)) {
throw new AssumptionViolatedException("HSCAN is only available for jedis and lettuce");
}
- if (connection.isPipelined() || connection.isQueueing()) {
+ if (isPipelinedOrQueueingConnection(connection)) {
throw new AssumptionViolatedException("HSCAN is only available in non pipeline | queue mode");
}
*