Skip to content

Commit 298139d

Browse files
committed
Polishing.
Fix inconsistencies, bugs, documentation, move types around, make specs immutable. Fix DataType literal. Refine exception guards. Enable CI for Valkey (bare, without JSON). Remove StringRedisJsonTemplate for now, update docs, introduce fluent delete/unlink API for key removal. See #3390
1 parent 8927add commit 298139d

56 files changed

Lines changed: 1965 additions & 1018 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/antora/modules/ROOT/pages/redis/template.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ While `[Reactive]RedisConnection` offers low-level methods that accept and retur
88

99
The javadoc:org.springframework.data.redis.core.RedisTemplate[] class implements the javadoc:org.springframework.data.redis.core.RedisOperations[] interface and its reactive variant javadoc:org.springframework.data.redis.core.ReactiveRedisTemplate[] implements javadoc:org.springframework.data.redis.core.ReactiveRedisOperations[].
1010

11+
To use https://redis.io/json/[Redis JSON], use javadoc:org.springframework.data.redis.core.RedisJsonTemplate[].
12+
You can use Redis JSON (being an additional module) through a separate entry point featuring a fluent API that is different from the existing `RedisTemplate` approach.
13+
1114
NOTE: The preferred way to reference operations on a `[Reactive]RedisTemplate` instance is through the
1215
`[Reactive]RedisOperations` interface.
1316

@@ -48,6 +51,9 @@ Imperative::
4851
|javadoc:org.springframework.data.redis.core.ZSetOperations[]
4952
|Redis zset (or sorted set) operations
5053

54+
|javadoc:org.springframework.data.redis.core.RedisJsonOperations[]
55+
|Redis JSON operations
56+
5157
2+^|_Key Bound Operations_
5258

5359
|javadoc:org.springframework.data.redis.core.BoundGeoOperations[]

src/main/java/org/springframework/data/redis/aot/RedisRuntimeHints.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
111111
TypeReference.of(ReactiveClusterHyperLogLogCommands.class), TypeReference.of(ReactiveRedisOperations.class),
112112
TypeReference.of(ReactiveRedisConnectionFactory.class), TypeReference.of(ReactiveRedisTemplate.class),
113113
TypeReference.of(RedisOperations.class), TypeReference.of(RedisTemplate.class),
114-
TypeReference.of(StringRedisTemplate.class), TypeReference.of(KeyspaceConfiguration.class),
114+
TypeReference.of(StringRedisTemplate.class), TypeReference.of(RedisJsonTemplate.class),
115+
TypeReference.of(StringRedisJsonTemplate.class), TypeReference.of(KeyspaceConfiguration.class),
115116
TypeReference.of(MappingConfiguration.class), TypeReference.of(MappingRedisConverter.class),
116117
TypeReference.of(RedisConverter.class), TypeReference.of(RedisCustomConversions.class),
117118
TypeReference.of(ReferenceResolver.class), TypeReference.of(ReferenceResolverImpl.class),
@@ -133,7 +134,6 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
133134
TypeReference.of("org.springframework.data.redis.core.DefaultStreamOperations"),
134135
TypeReference.of("org.springframework.data.redis.core.DefaultValueOperations"),
135136
TypeReference.of("org.springframework.data.redis.core.DefaultZSetOperations"),
136-
TypeReference.of("org.springframework.data.redis.core.DefaultJsonOperations"),
137137

138138
TypeReference.of(RedisKeyValueAdapter.class), TypeReference.of(RedisKeyValueTemplate.class),
139139

src/main/java/org/springframework/data/redis/config/RedisListenerEndpointRegistrar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void setEndpointRegistry(@Nullable RedisListenerEndpointRegistry endpoint
7373
}
7474

7575
/**
76-
* Return the {@link RedisListenerEndpointRegistry} instance for this registrar, may be {@code null}.
76+
* Return the {@link RedisListenerEndpointRegistry} instance for this registrar, may be {@literal null}.
7777
*/
7878
public @Nullable RedisListenerEndpointRegistry getEndpointRegistry() {
7979
return this.endpointRegistry;

src/main/java/org/springframework/data/redis/connection/DataType.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@
2929
public enum DataType {
3030

3131
NONE("none"), STRING("string"), LIST("list"), SET("set"), ZSET("zset"), HASH("hash"),
32+
3233
/**
3334
* @since 2.2
3435
*/
3536
STREAM("stream"),
37+
3638
/**
3739
* @since 4.2
3840
*/
39-
JSON("json");
41+
JSON("ReJSON-RL");
4042

4143
private static final Map<String, DataType> codeLookup = new ConcurrentHashMap<>(7);
4244

@@ -75,4 +77,5 @@ public static DataType fromCode(String code) {
7577
}
7678
return data;
7779
}
80+
7881
}

src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ public RedisHyperLogLogCommands hyperLogLogCommands() {
209209
return this;
210210
}
211211

212+
@Override
213+
public RedisJsonCommands jsonCommands() {
214+
return delegate.jsonCommands();
215+
}
216+
212217
@Override
213218
public RedisKeyCommands keyCommands() {
214219
return this;
@@ -249,11 +254,6 @@ public RedisZSetCommands zSetCommands() {
249254
return this;
250255
}
251256

252-
@Override
253-
public RedisJsonCommands jsonCommands() {
254-
return delegate.jsonCommands();
255-
}
256-
257257
@Override
258258
public Long append(byte[] key, byte[] value) {
259259
return convertAndReturn(delegate.append(key, value), Converters.identityConverter());

src/main/java/org/springframework/data/redis/connection/DefaultedRedisConnection.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import org.springframework.data.geo.Metric;
3333
import org.springframework.data.geo.Point;
3434
import org.springframework.data.redis.connection.json.JsonPath;
35+
import org.springframework.data.redis.connection.json.JsonSetCondition;
36+
import org.springframework.data.redis.connection.json.JsonType;
3537
import org.springframework.data.redis.connection.json.JsonValue;
3638
import org.springframework.data.redis.connection.stream.ByteRecord;
3739
import org.springframework.data.redis.connection.stream.Consumer;

src/main/java/org/springframework/data/redis/connection/RedisCommands.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
* @author Mark Paluch
2727
*/
2828
@NullUnmarked
29-
public interface RedisCommands extends RedisKeyCommands, RedisStringCommands, RedisListCommands, RedisSetCommands,
29+
public interface RedisCommands
30+
extends RedisKeyCommands, RedisJsonCommands, RedisStringCommands, RedisListCommands, RedisSetCommands,
3031
RedisZSetCommands, RedisHashCommands, RedisTxCommands, RedisPubSubCommands, RedisConnectionCommands,
31-
RedisServerCommands, RedisStreamCommands, RedisScriptingCommands, RedisGeoCommands, RedisHyperLogLogCommands,
32-
RedisJsonCommands {
32+
RedisServerCommands, RedisStreamCommands, RedisScriptingCommands, RedisGeoCommands, RedisHyperLogLogCommands {
3333

3434
/**
3535
* {@literal Native} or {@literal raw} execution of the given Redis command along with the given arguments.

src/main/java/org/springframework/data/redis/connection/RedisCommandsProvider.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ public interface RedisCommandsProvider {
5555
*/
5656
RedisHyperLogLogCommands hyperLogLogCommands();
5757

58+
/**
59+
* Get {@link RedisJsonCommands}.
60+
*
61+
* @return never {@literal null}.
62+
* @since 4.2
63+
*/
64+
RedisJsonCommands jsonCommands();
65+
5866
/**
5967
* Get {@link RedisKeyCommands}.
6068
*
@@ -119,12 +127,4 @@ public interface RedisCommandsProvider {
119127
*/
120128
RedisZSetCommands zSetCommands();
121129

122-
/**
123-
* Get {@link RedisJsonCommands}.
124-
*
125-
* @return never {@literal null}.
126-
* @since 4.2
127-
*/
128-
RedisJsonCommands jsonCommands();
129-
130130
}

0 commit comments

Comments
 (0)