Skip to content

Commit 1dc4905

Browse files
committed
Edit and cleanup Javadoc.
Resolves spring-projects#2586
1 parent 418121f commit 1dc4905

File tree

5 files changed

+50
-28
lines changed

5 files changed

+50
-28
lines changed

Diff for: src/main/java/org/springframework/data/redis/cache/RedisCache.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
/**
4343
* {@link org.springframework.cache.Cache} implementation using for Redis as the underlying store for cache data.
44-
*
44+
* <p>
4545
* Use {@link RedisCacheManager} to create {@link RedisCache} instances.
4646
*
4747
* @author Christoph Strobl
@@ -52,6 +52,7 @@
5252
* @see org.springframework.cache.support.AbstractValueAdaptingCache
5353
* @since 2.0
5454
*/
55+
@SuppressWarnings("unused")
5556
public class RedisCache extends AbstractValueAdaptingCache {
5657

5758
private static final byte[] BINARY_NULL_VALUE = RedisSerializer.java().serialize(NullValue.INSTANCE);
@@ -136,7 +137,8 @@ public <T> T get(Object key, Callable<T> valueLoader) {
136137
}
137138

138139
@SuppressWarnings("unchecked")
139-
private synchronized @Nullable <T> T getSynchronized(Object key, Callable<T> valueLoader) {
140+
@Nullable
141+
private synchronized <T> T getSynchronized(Object key, Callable<T> valueLoader) {
140142

141143
ValueWrapper result = get(key);
142144

Diff for: src/main/java/org/springframework/data/redis/cache/RedisCacheConfiguration.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
/**
3434
* Immutable {@link RedisCacheConfiguration} used to customize {@link RedisCache} behaviour, such as caching
3535
* {@literal null} values, computing cache key prefixes and handling binary serialization.
36-
*
36+
* <p>
3737
* Start with {@link RedisCacheConfiguration#defaultCacheConfig()} and customize {@link RedisCache} behaviour
3838
* from that point on.
3939
*
@@ -344,9 +344,9 @@ public void configureKeyConverters(Consumer<ConverterRegistry> registryConsumer)
344344

345345
/**
346346
* Registers default cache {@link Converter key converters}.
347-
*
347+
* <p>
348348
* The following converters get registered:
349-
*
349+
* <p>
350350
* <ul>
351351
* <li>{@link String} to {@link byte byte[]} using UTF-8 encoding.</li>
352352
* <li>{@link SimpleKey} to {@link String}</li>

Diff for: src/main/java/org/springframework/data/redis/connection/RedisCommands.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.springframework.lang.Nullable;
1919

2020
/**
21-
* Interface for the commands supported by Redis.
21+
* Interface defining the commands supported by Redis.
2222
*
2323
* @author Costin Leau
2424
* @author Christoph Strobl
@@ -29,14 +29,16 @@ public interface RedisCommands extends RedisKeyCommands, RedisStringCommands, Re
2929
RedisServerCommands, RedisStreamCommands, RedisScriptingCommands, RedisGeoCommands, RedisHyperLogLogCommands {
3030

3131
/**
32-
* 'Native' or 'raw' execution of the given command along-side the given arguments. The command is executed as is,
33-
* with as little 'interpretation' as possible - it is up to the caller to take care of any processing of arguments or
34-
* the result.
32+
* {@literal Native} or {@literal raw} execution of the given Redis command along with the given arguments.
33+
* <p>
34+
* The command is executed as is, with as little interpretation as possible - it is up to the caller to take care
35+
* of any processing of arguments or the result.
3536
*
36-
* @param command Command to execute. must not be {@literal null}.
37-
* @param args Possible command arguments (may be empty).
38-
* @return execution result. Can be {@literal null}.
37+
* @param command Redis {@link String command} to execute; must not be {@literal null}.
38+
* @param args optional array of command arguments; may be empty;
39+
* @return the execution result; may be {@literal null}.
3940
*/
4041
@Nullable
4142
Object execute(String command, byte[]... args);
43+
4244
}

Diff for: src/main/java/org/springframework/data/redis/core/RedisCallback.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,22 @@
2525
* {@code get/set/trim etc...}.
2626
*
2727
* @author Costin Leau
28+
* @author John Blum
2829
*/
2930
public interface RedisCallback<T> {
3031

3132
/**
32-
* Gets called by {@link RedisTemplate} with an active Redis connection. Does not need to care about activating or
33-
* closing the connection or handling exceptions.
33+
* Method called by {@link RedisTemplate} with an active {@link RedisConnection}.
34+
* <p>
35+
* Callback code need not care about activating/opening or closing the {@link RedisConnection},
36+
* nor handling {@link Exception exceptions}.
3437
*
35-
* @param connection active Redis connection
36-
* @return a result object or {@code null} if none
37-
* @throws DataAccessException
38+
* @param connection active {@link RedisConnection Redis connection}.
39+
* @return the {@link Object result} of the operation performed in the callback or {@code null}.
40+
* @throws DataAccessException if the operation performed by the callback fails to execute in the context of Redis
41+
* using the given {@link RedisConnection}.
3842
*/
3943
@Nullable
4044
T doInRedis(RedisConnection connection) throws DataAccessException;
45+
4146
}

Diff for: src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java

+24-11
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,18 @@ public abstract class AbstractConnectionIntegrationTests {
131131

132132
protected RedisConnection byteConnection;
133133

134+
private boolean isJedisOrLettuceConnection(RedisConnectionFactory connectionFactory) {
135+
return ConnectionUtils.isJedis(connectionFactory) || ConnectionUtils.isLettuce(connectionFactory);
136+
}
137+
138+
private boolean isNotJedisOrLettuceConnection(RedisConnectionFactory connectionFactory) {
139+
return !isJedisOrLettuceConnection(connectionFactory);
140+
}
141+
142+
private boolean isPipelinedOrQueueingConnection(RedisConnection connection) {
143+
return connection.isPipelined() || connection.isQueueing();
144+
}
145+
134146
@BeforeEach
135147
public void setUp() {
136148

@@ -2595,12 +2607,12 @@ public void testListClientsContainsAtLeastOneElement() {
25952607
@Test // DATAREDIS-290
25962608
void scanShouldReadEntireValueRange() {
25972609

2598-
if (!ConnectionUtils.isJedis(connectionFactory) && !ConnectionUtils.isLettuce(connectionFactory)) {
2610+
if (isNotJedisOrLettuceConnection(connectionFactory)) {
25992611
throw new AssumptionViolatedException("SCAN is only available for jedis and lettuce");
26002612
}
26012613

2602-
if (connection.isPipelined() || connection.isQueueing()) {
2603-
throw new AssumptionViolatedException("SCAN is only available in non pipeline | queue mode");
2614+
if (isPipelinedOrQueueingConnection(connection)) {
2615+
throw new AssumptionViolatedException("SCAN is only available in non-pipeline | non-queueing mode");
26042616
}
26052617

26062618
connection.set("spring", "data");
@@ -2626,8 +2638,9 @@ void scanShouldReadEntireValueRange() {
26262638
@EnabledOnRedisVersion("6.0")
26272639
void scanWithType() {
26282640

2629-
assumeThat(connection.isPipelined() || connection.isQueueing())
2630-
.describedAs("SCAN is only available in non pipeline | queue mode").isFalse();
2641+
assumeThat(isPipelinedOrQueueingConnection(connection))
2642+
.describedAs("SCAN is only available in non-pipeline | non-queueing mode")
2643+
.isFalse();
26312644

26322645
connection.set("key", "data");
26332646
connection.lPush("list", "foo");
@@ -2670,11 +2683,11 @@ public void scanShouldReadEntireValueRangeWhenIdividualScanIterationsReturnEmpty
26702683
@Test // DATAREDIS-306
26712684
void zScanShouldReadEntireValueRange() {
26722685

2673-
if (!ConnectionUtils.isJedis(connectionFactory) && !ConnectionUtils.isLettuce(connectionFactory)) {
2686+
if (isNotJedisOrLettuceConnection(connectionFactory)) {
26742687
throw new AssumptionViolatedException("ZSCAN is only available for jedis and lettuce");
26752688
}
26762689

2677-
if (connection.isPipelined() || connection.isQueueing()) {
2690+
if (isPipelinedOrQueueingConnection(connection)) {
26782691
throw new AssumptionViolatedException("ZSCAN is only available in non pipeline | queue mode");
26792692
}
26802693

@@ -2701,11 +2714,11 @@ void zScanShouldReadEntireValueRange() {
27012714
@Test // DATAREDIS-304
27022715
void sScanShouldReadEntireValueRange() {
27032716

2704-
if (!ConnectionUtils.isJedis(connectionFactory) && !ConnectionUtils.isLettuce(connectionFactory)) {
2717+
if (isNotJedisOrLettuceConnection(connectionFactory)) {
27052718
throw new AssumptionViolatedException("SCAN is only available for jedis and lettuce");
27062719
}
27072720

2708-
if (connection.isPipelined() || connection.isQueueing()) {
2721+
if (isPipelinedOrQueueingConnection(connection)) {
27092722
throw new AssumptionViolatedException("SCAN is only available in non pipeline | queue mode");
27102723
}
27112724

@@ -2726,11 +2739,11 @@ void sScanShouldReadEntireValueRange() {
27262739
@Test // DATAREDIS-305
27272740
void hScanShouldReadEntireValueRange() {
27282741

2729-
if (!ConnectionUtils.isJedis(connectionFactory) && !ConnectionUtils.isLettuce(connectionFactory)) {
2742+
if (isNotJedisOrLettuceConnection(connectionFactory)) {
27302743
throw new AssumptionViolatedException("HSCAN is only available for jedis and lettuce");
27312744
}
27322745

2733-
if (connection.isPipelined() || connection.isQueueing()) {
2746+
if (isPipelinedOrQueueingConnection(connection)) {
27342747
throw new AssumptionViolatedException("HSCAN is only available in non pipeline | queue mode");
27352748
}
27362749

0 commit comments

Comments
 (0)