DATAREDIS-619 - Housekeeping.

Remove leftovers from SRP and JRedis removal. Reference bundled Spring Framework version in documentation links. Update outdated links. Upgrade to Java 8 requirements. Order operations interfaces alphabetically (documentation, code) and update what's new section.

Original Pull Request: #280
This commit is contained in:
Mark Paluch
2017-09-14 14:36:05 +02:00
committed by Christoph Strobl
parent b8b091d7ce
commit e64f60b6a2
9 changed files with 427 additions and 411 deletions

View File

@@ -11,7 +11,7 @@ As explained in <<why-spring-redis>>, Spring Data Redis (SDR) provides integrati
[[get-started:first-steps:spring]]
=== Knowing Spring
Spring Data uses heavily Spring framework's http://docs.spring.io/spring/docs/current/spring-framework-reference/html/spring-core.html[core] functionality, such as the http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html[IoC] container, http://docs.spring.io/spring/docs/current/spring-framework-reference/html/resources.html[resource] abstract or http://docs.spring.io/spring/docs/current/spring-framework-reference/html/aop.html[AOP] infrastructure. While it is not important to know the Spring APIs, understanding the concepts behind them is. At a minimum, the idea behind IoC should be familiar. That being said, the more knowledge one has about the Spring, the faster she will pick up Spring Data Redis. Besides the very comprehensive (and sometimes disarming) documentation that explains in detail the Spring Framework, there are a lot of articles, blog entries and books on the matter - take a look at the Spring Guides http://spring.io/guides[home page] for more information. In general, this should be the starting point for developers wanting to try Spring DR.
Spring Data uses heavily Spring framework's http://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html[core] functionality, such as the http://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html[IoC] container, http://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html#resources[resource] abstract or http://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/core.html#aop[AOP] infrastructure. While it is not important to know the Spring APIs, understanding the concepts behind them is. At a minimum, the idea behind IoC should be familiar. That being said, the more knowledge one has about the Spring, the faster she will pick up Spring Data Redis. Besides the very comprehensive (and sometimes disarming) documentation that explains in detail the Spring Framework, there are a lot of articles, blog entries and books on the matter - take a look at the Spring Guides http://spring.io/guides[home page] for more information. In general, this should be the starting point for developers wanting to try Spring DR.
[[get-started:first-steps:nosql]]
=== Knowing NoSQL and Key Value stores
@@ -36,7 +36,7 @@ The Spring Data tag on http://stackoverflow.com/questions/tagged/spring-data[Sta
[[get-started:help:professional]]
=== Professional Support
Professional, from-the-source support, with guaranteed response time, is available from http://www.gopivotal.com/[Pivotal Software, Inc.], the company behind Spring Data and Spring.
Professional, from-the-source support, with guaranteed response time, is available from http://www.pivotal.io/[Pivotal Software, Inc.], the company behind Spring Data and Spring.
[[get-started:up-to-date]]
== Following Development
@@ -50,5 +50,5 @@ If you encounter a bug or want to suggest an improvement, please create a ticket
To stay up to date with the latest news and announcements in the Spring eco system, subscribe to the Spring Community http://spring.io/[Portal].
Lastly, you can follow the Spring http://spring.io/blog/[blog] or the project team (http://twitter.com/thomasdarimont[Thomas] and http://twitter.com/stroblchristoph[Christoph]) on Twitter.
Lastly, you can follow the Spring http://spring.io/blog/[blog] or the project team (http://twitter.com/SpringData[@SpringData]) on Twitter.

View File

@@ -7,14 +7,14 @@ New and noteworthy in the latest releases.
== New in Spring Data Redis 2.0
* Upgrade to Java 8.
* Upgrade to Lettuce 5.0.
* Removed support for SRP and JRedis drivers.
* Upgrade to `Lettuce` 5.0.
* Reactive connection support using https://github.com/lettuce-io/lettuce-core[lettuce-io/lettuce-core].
* <<redis:reactive,Reactive connection support using Lettuce>>.
* Introduce Redis feature-specific interfaces for `RedisConnection`.
* Improved `RedisConnectionFactory` configuration via `JedisClientConfiguration` and `LettuceClientConfiguration`.
* Revised `RedisCache` implementation.
* Add `SPOP` with count command for Redis 3.2.
[[new-in-1.8.0]]
== New in Spring Data Redis 1.8

View File

@@ -3,8 +3,6 @@
Working with http://redis.io/topics/cluster-spec[Redis Cluster] requires a Redis Server version 3.0+ and provides a very own set of features and capabilities. Please refer to the http://redis.io/topics/cluster-tutorial[Cluster Tutorial] for more information.
TIP: Redis Cluster is only supported by <<redis:connectors:jedis,jedis>> and <<redis:connectors:lettuce,lettuce>>.
== Enabling Redis Cluster
Cluster support is based on the very same building blocks as non clustered communication. `RedisClusterConnection` an extension to `RedisConnection` handles the communication with the Redis Cluster and translates errors into the Spring DAO exception hierarchy.
@@ -65,7 +63,7 @@ public class AppConfig {
- `spring.redis.cluster.max-redirects`: Number of allowed cluster redirections.
====
NOTE: The initial configuration points driver libraries to an initial set of cluster nodes. Changes resulting from live cluster reconfiguration will only be kept in the native driver and not be written back to the configuration.
NOTE: The initial configuration points driver libraries to an initial set of cluster nodes. Changes resulting from live cluster reconfiguration will only be kept in the native driver and not be written back to the configuration.
== Working With Redis Cluster Connection
@@ -146,13 +144,13 @@ connection.mGet("foo", "bar"); <
-> 127.0.0.1:7381 GET foo
====
TIP: The above provided simple examples to demonstrate the general strategy followed by Spring Data Redis. Be aware that some operations might require loading huge amounts of data into memory in order to compute the desired command. Additionally not all cross slot requests can safely be ported to multiple single slot requests and will error if misused (eg. `PFCOUNT` ).
TIP: The above provided simple examples to demonstrate the general strategy followed by Spring Data Redis. Be aware that some operations might require loading huge amounts of data into memory in order to compute the desired command. Additionally not all cross slot requests can safely be ported to multiple single slot requests and will error if misused (eg. ``PFCOUNT``).
== Working With RedisTemplate and ClusterOperations
Please refer to the section <<redis:template>> to read about general purpose, configuration and usage of `RedisTemplate`.
WARNING: Please be careful when setting up `RedisTemplate#keySerializer` using any of the Json `RedisSerializers` as changing json structure has immediate influence on hash slot calculation.
WARNING: Please be careful when setting up `RedisTemplate#keySerializer` using any of the JSON `RedisSerializers` as changing json structure has immediate influence on hash slot calculation.
`RedisTemplate` provides access to cluster specific operations via the `ClusterOperations` interface that can be obtained via `RedisTemplate.opsForCluster()`. This allows to execute commands explicitly on a single node within the cluster while retaining de-/serialization features configured for the template and provides administrative commands such as `CLUSTER MEET` or more high level operations for eg. resharding.

View File

@@ -18,7 +18,7 @@ To publish a message, one can use, as with the other operations, either the low-
byte[] msg = ...
byte[] channel = ...
con.publish(msg, channel); // send message through RedisTemplate
RedisTemplate template = ...
RedisTemplate template = ...
template.convertAndSend("hello!", "world");
----
@@ -29,7 +29,7 @@ On the receiving side, one can subscribe to one or multiple channels either by n
At the low-level, `RedisConnection` offers `subscribe` and `pSubscribe` methods that map the Redis commands for subscribing by channel respectively by pattern. Note that multiple channels or patterns can be used as arguments. To change the subscription of a connection or simply query whether it is listening or not, `RedisConnection` provides `getSubscription` and `isSubscribed` method.
NOTE: Subscription commands in Spring Data Redis are blocking. That is, calling subscribe on a connection will cause the current thread to block as it will start waiting for messages - the thread will be released only if the subscription is canceled, that is an additional thread invokes `unsubscribe` or `pUnsubscribe` on the *same* connection. See <<null,message listener container>> below for a solution to this problem.
NOTE: Subscription commands in Spring Data Redis are blocking. That is, calling subscribe on a connection will cause the current thread to block as it will start waiting for messages - the thread will be released only if the subscription is canceled, that is an additional thread invokes `unsubscribe` or `pUnsubscribe` on the *same* connection. See <<redis:pubsub:subscribe:containers,message listener container>> below for a solution to this problem.
As mentioned above, once subscribed a connection starts waiting for messages. No other commands can be invoked on it except for adding new subscriptions or modifying/canceling the existing ones. That is, invoking anything other then `subscribe`, `pSubscribe`, `unsubscribe`, or `pUnsubscribe` is illegal and will throw an exception.
@@ -55,18 +55,18 @@ Consider the following interface definition. Notice that although the interface
[source,java]
----
public interface MessageDelegate {
public interface MessageDelegate {
void handleMessage(String message);
void handleMessage(Map message); void handleMessage(byte[] message);
void handleMessage(Map message); void handleMessage(byte[] message);
void handleMessage(Serializable message);
// pass the channel/pattern as well
void handleMessage(Serializable message, String channel);
// pass the channel/pattern as well
void handleMessage(Serializable message, String channel);
}
----
[source,java]
----
public class DefaultMessageDelegate implements MessageDelegate {
public class DefaultMessageDelegate implements MessageDelegate {
// implementation elided for clarity...
}
----
@@ -76,20 +76,20 @@ In particular, note how the above implementation of the `MessageDelegate` interf
[source,xml]
----
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:redis="http://www.springframework.org/schema/redis"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/redis http://www.springframework.org/schema/redis/spring-redis.xsd">
<!-- the default ConnectionFactory -->
<redis:listener-container>
<!-- the method attribute can be skipped as the default method name is "handleMessage" -->
<redis:listener ref="listener" method="handleMessage" topic="chatroom" />
</redis:listener-container>
<bean id="listener" class="redisexample.DefaultMessageDelegate"/>
...
...
<beans>
----
@@ -99,23 +99,23 @@ The example above uses the Redis namespace to declare the message listener conta
[source,xml]
----
<bean id="messageListener" class="org.springframework.data.redis.listener.adapter.MessageListenerAdapter">
<bean id="messageListener" class="org.springframework.data.redis.listener.adapter.MessageListenerAdapter">
<constructor-arg>
<bean class="redisexample.DefaultMessageDelegate"/>
</constructor-arg>
</bean>
<bean id="redisContainer" class="org.springframework.data.redis.listener.RedisMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="messageListeners">
<map>
<entry key-ref="messageListener">
<bean class="org.springframework.data.redis.listener.ChannelTopic">
<bean class="org.springframework.data.redis.listener.ChannelTopic">
<constructor-arg value="chatroom">
</bean>
</entry>
</map>
</property>
</property>
</bean>
----

View File

@@ -12,7 +12,7 @@ Spring Data Redis provides easy configuration and access to Redis from Spring ap
[[redis:requirements]]
== Redis Requirements
Spring Redis requires Redis 2.6 or above and Java SE 6.0 or above . In terms of language bindings (or connectors), Spring Redis integrates with http://github.com/xetorthio/jedis[Jedis] and http://github.com/mp911de/lettuce[Lettuce], four popular open source Java libraries for Redis. If you are aware of any other connector that we should be integrating with please send us feedback.
Spring Redis requires Redis 2.6 or above and Java SE 8.0 or above. In terms of language bindings (or connectors), Spring Redis integrates with http://github.com/xetorthio/jedis[Jedis] and http://github.com/lettuce-io/lettuce-core[Lettuce], two popular open source Java libraries for Redis.
[[redis:architecture]]
== Redis Support High Level View
@@ -29,11 +29,11 @@ One of the first tasks when using Redis and Spring is to connect to the store th
[[redis:connectors:connection]]
=== RedisConnection and RedisConnectionFactory
`RedisConnection` provides the building block for Redis communication as it handles the communication with the Redis back-end. It also automatically translates the underlying connecting library exceptions to Spring's consistent DAO exception http://docs.spring.io/spring/docs/current/spring-framework-reference/html/dao.html#dao-exceptions[hierarchy] so one can switch the connectors without any code changes as the operation semantics remain the same.
`RedisConnection` provides the building block for Redis communication as it handles the communication with the Redis back-end. It also automatically translates the underlying connecting library exceptions to Spring's consistent DAO exception http://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/data-access.html#dao-exceptions[hierarchy] so one can switch the connectors without any code changes as the operation semantics remain the same.
NOTE: For the corner cases where the native library API is required, `RedisConnection` provides a dedicated method `getNativeConnection` which returns the raw, underlying object used for communication.
Active `RedisConnection` s are created through `RedisConnectionFactory`. In addition, the factories act as `PersistenceExceptionTranslator` s, meaning once declared, they allow one to do transparent exception translation. For example, exception translation through the use of the `@Repository` annotation and AOP. For more information see the dedicated http://docs.spring.io/spring/docs/current/spring-framework-reference/html/orm.html#orm-exception-translation[section] in Spring Framework documentation.
Active `RedisConnection` s are created through `RedisConnectionFactory`. In addition, the factories act as `PersistenceExceptionTranslator` s, meaning once declared, they allow one to do transparent exception translation. For example, exception translation through the use of the `@Repository` annotation and AOP. For more information see the dedicated http://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/data-access.html#orm-exception-translation[section] in Spring Framework documentation.
NOTE: Depending on the underlying configuration, the factory can return a new connection or an existing connection (in case a pool or shared native connection is used).
@@ -78,7 +78,7 @@ For production use however, one might want to tweak the settings such as the hos
[[redis:connectors:lettuce]]
=== Configuring Lettuce connector
https://github.com/mp911de/lettuce[Lettuce] is the fourth open-source connector supported by Spring Data Redis through the `org.springframework.data.redis.connection.lettuce` package.
https://github.com/mp911de/lettuce[Lettuce] is a http://netty.io/[netty]-based open-source connector supported by Spring Data Redis through the `org.springframework.data.redis.connection.lettuce` package.
Its configuration is probably easy to guess:
@@ -102,8 +102,6 @@ There are also a few Lettuce-specific connection parameters that can be tweaked.
For dealing with high available Redis there is support for http://redis.io/topics/sentinel[Redis Sentinel] using `RedisSentinelConfiguration`.
NOTE: Please note that currently only http://github.com/xetorthio/jedis[Jedis] and lettuce http://github.com/mp911de/lettuce[Lettuce] support Redis Sentinel.
[source,java]
----
/**
@@ -111,18 +109,22 @@ NOTE: Please note that currently only http://github.com/xetorthio/jedis[Jedis] a
*/
@Bean
public RedisConnectionFactory jedisConnectionFactory() {
RedisSentinelConfiguration sentinelConfig = new RedisSentinelConfiguration() .master("mymaster")
.sentinel("127.0.0.1", 26379) .sentinel("127.0.0.1", 26380);
RedisSentinelConfiguration sentinelConfig = new RedisSentinelConfiguration()
.master("mymaster")
.sentinel("127.0.0.1", 26379)
.sentinel("127.0.0.1", 26380);
return new JedisConnectionFactory(sentinelConfig);
}
/**
* lettuce
* Lettuce
*/
@Bean
public RedisConnectionFactory lettuceConnectionFactory() {
RedisSentinelConfiguration sentinelConfig = new RedisSentinelConfiguration().master("mymaster")
.sentinel("127.0.0.1", 26379) .sentinel("127.0.0.1", 26380);
RedisSentinelConfiguration sentinelConfig = new RedisSentinelConfiguration()
.master("mymaster")
.sentinel("127.0.0.1", 26379)
.sentinel("127.0.0.1", 26380);
return new LettuceConnectionFactory(sentinelConfig);
}
----
@@ -138,11 +140,10 @@ public RedisConnectionFactory lettuceConnectionFactory() {
Sometimes direct interaction with the one of the Sentinels is required. Using `RedisConnectionFactory.getSentinelConnection()` or `RedisConnection.getSentinelCommands()` gives you access to the first active Sentinel configured.
[[redis:template]]
== Working with Objects through RedisTemplate
Most users are likely to use `RedisTemplate` and its coresponding package `org.springframework.data.redis.core` - the template is in fact the central class of the Redis module due to its rich feature set. The template offers a high-level abstraction for Redis interactions. While `RedisConnection` offers low level methods that accept and return binary values (`byte` arrays), the template takes care of serialization and connection management, freeing the user from dealing with such details.
Most users are likely to use `RedisTemplate` and its corresponding package `org.springframework.data.redis.core` - the template is in fact the central class of the Redis module due to its rich feature set. The template offers a high-level abstraction for Redis interactions. While `RedisConnection` offers low level methods that accept and return binary values (`byte` arrays), the template takes care of serialization and connection management, freeing the user from dealing with such details.
Moreover, the template provides operations views (following the grouping from Redis command http://redis.io/commands[reference]) that offer rich, generified interfaces for working against a certain type or certain key (through the `KeyBound` interfaces) as described below:
@@ -154,8 +155,14 @@ Moreover, the template provides operations views (following the grouping from Re
2+^|_Key Type Operations_
|ValueOperations
|Redis string (or value) operations
|GeoOperations
|Redis geospatial operations like `GEOADD`, `GEORADIUS`,...)
|HashOperations
|Redis hash operations
|HyperLogLogOperations
|Redis HyperLogLog operations like (`PFADD`, `PFCOUNT`,...)
|ListOperations
|Redis list operations
@@ -163,22 +170,22 @@ Moreover, the template provides operations views (following the grouping from Re
|SetOperations
|Redis set operations
|ValueOperations
|Redis string (or value) operations
|ZSetOperations
|Redis zset (or sorted set) operations
|HashOperations
|Redis hash operations
|HyperLogLogOperations
|Redis HyperLogLog operations like (pfadd, pfcount,...)
|GeoOperations
|Redis geospatial operations like `GEOADD`, `GEORADIUS`,...)
2+^|_Key Bound Operations_
|BoundValueOperations
|Redis string (or value) key bound operations
|BoundGeoOperations
|Redis key bound geospatial operations.
|BoundHashOperations
|Redis hash key bound operations
|BoundKeyOperations
|Redis key bound operations
|BoundListOperations
|Redis list key bound operations
@@ -186,14 +193,12 @@ Moreover, the template provides operations views (following the grouping from Re
|BoundSetOperations
|Redis set key bound operations
|BoundValueOperations
|Redis string (or value) key bound operations
|BoundZSetOperations
|Redis zset (or sorted set) key bound operations
|BoundHashOperations
|Redis hash key bound operations
|BoundGeoOperations
|Redis key bound geospatial operations.
|====
Once configured, the template is thread-safe and can be reused across multiple instances.
@@ -290,9 +295,21 @@ public void useCallback() {
From the framework perspective, the data stored in Redis is just bytes. While Redis itself supports various types, for the most part these refer to the way the data is stored rather than what it represents. It is up to the user to decide whether the information gets translated into Strings or any other objects.
The conversion between the user (custom) types and raw data (and vice-versa) is handled in Spring Data Redis through the `RedisSerializer` interface (package `org.springframework.data.redis.serializer`) which as the name implies, takes care of the serialization process.
The conversion between the user (custom) types and raw data (and vice-versa) is handled in Spring Data Redis in the `org.springframework.data.redis.serializer` package.
Multiple implementations are available out of the box, two of which have been already mentioned before in this documentation: the `StringRedisSerializer` and the `JdkSerializationRedisSerializer`. However one can use `OxmSerializer` for Object/XML mapping through Spring 3 http://docs.spring.io/spring/docs/current/spring-framework-reference/html/oxm.html[OXM] support or either `Jackson2JsonRedisSerializer` or `GenericJackson2JsonRedisSerializer` for storing data in http://en.wikipedia.org/wiki/JSON[JSON] format.
This package contains two types of serializers which as the name implies, takes care of the serialization process:
* Two-way serializers based on`RedisSerializer`.
* Element readers and writers using `RedisElementReader` and `RedisElementWriter`.
The main difference between these variants is that `RedisSerializer` primarily serializes to `byte[]` while readers and writers use `ByteBuffer`.
Multiple implementations are available out of the box, two of which have been already mentioned before in this documentation:
* the `StringRedisSerializer`
* `JdkSerializationRedisSerializer`
However one can use `OxmSerializer` for Object/XML mapping through Spring http://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/data-access.html#oxm[OXM] support or either `Jackson2JsonRedisSerializer` or `GenericJackson2JsonRedisSerializer` for storing data in http://en.wikipedia.org/wiki/JSON[JSON] format.
Do note that the storage format is not limited only to values - it can be used for keys, values or hashes without any restrictions.
@@ -313,7 +330,7 @@ Hash mappers are converters to map objects to a `Map<K, V>` and back. `HashMappe
Multiple implementations are available out of the box:
1. `BeanUtilsHashMapper` using Spring's http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/beans/BeanUtils.html[BeanUtils].
1. `BeanUtilsHashMapper` using Spring's http://docs.spring.io/spring/docs/{springVersion}/javadoc-api/org/springframework/beans/BeanUtils.html[BeanUtils].
2. `ObjectHashMapper` using <<redis.repositories.mapping>>.
3. <<redis.hashmappers.jackson2,`Jackson2HashMapper`>> using https://github.com/FasterXML/jackson[FasterXML Jackson].
@@ -423,8 +440,8 @@ include::{referenceDir}/redis-scripting.adoc[]
== Support Classes
Package `org.springframework.data.redis.support` offers various reusable components that rely on Redis as a backing store. Currently the package contains various JDK-based
interface implementations on top of Redis such as http://download.oracle.com/javase/6/docs/api/java/util/concurrent/atomic/package-summary.html[atomic] counters and JDK
http://download.oracle.com/javase/6/docs/api/java/util/Collection.html[Collections].
interface implementations on top of Redis such as http://download.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/package-summary.html[atomic] counters and JDK
http://download.oracle.com/javase/8/docs/api/java/util/Collection.html[Collections].
The atomic counters make it easy to wrap Redis key incrementation while the collections allow easy management of Redis keys with minimal storage exposure or API
leakage: in particular the `RedisSet` and `RedisZSet` interfaces offer easy access to the *set* operations supported by Redis such as `intersection` and `union`
@@ -467,7 +484,7 @@ As shown in the example above, the consuming code is decoupled from the actual s
NOTE: Changed in 2.0
Spring Redis provides an implementation for Spring http://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html[cache abstraction] through the `org.springframework.data.redis.cache` package. To use Redis as a backing implementation, simply add `RedisCacheManager` to your configuration:
Spring Redis provides an implementation for Spring http://docs.spring.io/spring/docs/{springVersion}/spring-framework-reference/integration.html#cache[cache abstraction] through the `org.springframework.data.redis.cache` package. To use Redis as a backing implementation, simply add `RedisCacheManager` to your configuration:
[source,java]
----

View File

@@ -239,20 +239,53 @@ public interface ReactiveRedisOperations<K, V> {
// operation types
/**
* Returns the operations performed on simple values (or Strings in Redis terminology).
* Returns geospatial specific operations interface.
*
* @return value operations
* @return geospatial specific operations.
*/
ReactiveValueOperations<K, V> opsForValue();
ReactiveGeoOperations<K, V> opsForGeo();
/**
* Returns the operations performed on simple values (or Strings in Redis terminology) given a
* {@link RedisSerializationContext}.
* Returns geospatial specific operations interface.
*
* @param serializationContext serializers to be used with the returned operations, must not be {@literal null}.
* @return value operations.
* @return geospatial specific operations.
*/
<K, V> ReactiveValueOperations<K, V> opsForValue(RedisSerializationContext<K, V> serializationContext);
<K, V> ReactiveGeoOperations<K, V> opsForGeo(RedisSerializationContext<K, V> serializationContext);
/**
* Returns the operations performed on hash values.
*
* @param <HK> hash key (or field) type.
* @param <HV> hash value type.
* @return hash operations.
*/
<HK, HV> ReactiveHashOperations<K, HK, HV> opsForHash();
/**
* Returns the operations performed on hash values given a {@link RedisSerializationContext}.
*
* @param serializationContext serializers to be used with the returned operations, must not be {@literal null}.
* @param <HK> hash key (or field) type.
* @param <HV> hash value type.
* @return hash operations.
*/
<K, HK, HV> ReactiveHashOperations<K, HK, HV> opsForHash(RedisSerializationContext<K, ?> serializationContext);
/**
* Returns the operations performed on multisets using HyperLogLog.
*
* @return never {@literal null}.
*/
ReactiveHyperLogLogOperations<K, V> opsForHyperLogLog();
/**
* Returns the operations performed on multisets using HyperLogLog given a {@link RedisSerializationContext}.
*
* @param serializationContext serializers to be used with the returned operations, must not be {@literal null}.
* @return never {@literal null}.
*/
<K, V> ReactiveHyperLogLogOperations<K, V> opsForHyperLogLog(RedisSerializationContext<K, V> serializationContext);
/**
* Returns the operations performed on list values.
@@ -284,6 +317,22 @@ public interface ReactiveRedisOperations<K, V> {
*/
<K, V> ReactiveSetOperations<K, V> opsForSet(RedisSerializationContext<K, V> serializationContext);
/**
* Returns the operations performed on simple values (or Strings in Redis terminology).
*
* @return value operations
*/
ReactiveValueOperations<K, V> opsForValue();
/**
* Returns the operations performed on simple values (or Strings in Redis terminology) given a
* {@link RedisSerializationContext}.
*
* @param serializationContext serializers to be used with the returned operations, must not be {@literal null}.
* @return value operations.
*/
<K, V> ReactiveValueOperations<K, V> opsForValue(RedisSerializationContext<K, V> serializationContext);
/**
* Returns the operations performed on zset values (also known as sorted sets).
*
@@ -300,55 +349,6 @@ public interface ReactiveRedisOperations<K, V> {
*/
<K, V> ReactiveZSetOperations<K, V> opsForZSet(RedisSerializationContext<K, V> serializationContext);
/**
* Returns the operations performed on multisets using HyperLogLog.
*
* @return never {@literal null}.
*/
ReactiveHyperLogLogOperations<K, V> opsForHyperLogLog();
/**
* Returns the operations performed on multisets using HyperLogLog given a {@link RedisSerializationContext}.
*
* @param serializationContext serializers to be used with the returned operations, must not be {@literal null}.
* @return never {@literal null}.
*/
<K, V> ReactiveHyperLogLogOperations<K, V> opsForHyperLogLog(RedisSerializationContext<K, V> serializationContext);
/**
* Returns the operations performed on hash values.
*
* @param <HK> hash key (or field) type.
* @param <HV> hash value type.
* @return hash operations.
*/
<HK, HV> ReactiveHashOperations<K, HK, HV> opsForHash();
/**
* Returns the operations performed on hash values given a {@link RedisSerializationContext}.
*
* @param serializationContext serializers to be used with the returned operations, must not be {@literal null}.
* @param <HK> hash key (or field) type.
* @param <HV> hash value type.
* @return hash operations.
*/
<K, HK, HV> ReactiveHashOperations<K, HK, HV> opsForHash(RedisSerializationContext<K, ?> serializationContext);
/**
* Returns geospatial specific operations interface.
*
* @return geospatial specific operations.
*/
ReactiveGeoOperations<K, V> opsForGeo();
/**
* Returns geospatial specific operations interface.
*
* @param serializationContext serializers to be used with the returned operations, must not be {@literal null}.
* @return geospatial specific operations.
*/
<K, V> ReactiveGeoOperations<K, V> opsForGeo(RedisSerializationContext<K, V> serializationContext);
/**
* @return the {@link RedisSerializationContext}.
*/

View File

@@ -102,119 +102,6 @@ public class ReactiveRedisTemplate<K, V> implements ReactiveRedisOperations<K, V
return connectionFactory;
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForValue()
*/
@Override
public ReactiveValueOperations<K, V> opsForValue() {
return opsForValue(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForValue(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, V1> ReactiveValueOperations<K1, V1> opsForValue(RedisSerializationContext<K1, V1> serializationContext) {
return new DefaultReactiveValueOperations<>(this, serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForList()
*/
@Override
public ReactiveListOperations<K, V> opsForList() {
return opsForList(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForList(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, V1> ReactiveListOperations<K1, V1> opsForList(RedisSerializationContext<K1, V1> serializationContext) {
return new DefaultReactiveListOperations<>(this, serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForSet()
*/
@Override
public ReactiveSetOperations<K, V> opsForSet() {
return opsForSet(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForSet(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, V1> ReactiveSetOperations<K1, V1> opsForSet(RedisSerializationContext<K1, V1> serializationContext) {
return new DefaultReactiveSetOperations<>(this, serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForZSet()
*/
@Override
public ReactiveZSetOperations<K, V> opsForZSet() {
return opsForZSet(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForZSet(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, V1> ReactiveZSetOperations<K1, V1> opsForZSet(RedisSerializationContext<K1, V1> serializationContext) {
return new DefaultReactiveZSetOperations<>(this, serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForHyperLogLog()
*/
@Override
public ReactiveHyperLogLogOperations<K, V> opsForHyperLogLog() {
return opsForHyperLogLog(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForHyperLogLog(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, V1> ReactiveHyperLogLogOperations<K1, V1> opsForHyperLogLog(
RedisSerializationContext<K1, V1> serializationContext) {
return new DefaultReactiveHyperLogLogOperations<>(this, serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForHash()
*/
@Override
public <HK, HV> ReactiveHashOperations<K, HK, HV> opsForHash() {
return opsForHash(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForHash(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, HK, HV> ReactiveHashOperations<K1, HK, HV> opsForHash(
RedisSerializationContext<K1, ?> serializationContext) {
return new DefaultReactiveHashOperations<>(this, serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForGeo()
*/
@Override
public ReactiveGeoOperations<K, V> opsForGeo() {
return opsForGeo(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForGeo(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, V1> ReactiveGeoOperations<K1, V1> opsForGeo(RedisSerializationContext<K1, V1> serializationContext) {
return new DefaultReactiveGeoOperations<>(this, serializationContext);
}
// -------------------------------------------------------------------------
// Execution methods
@@ -548,6 +435,120 @@ public class ReactiveRedisTemplate<K, V> implements ReactiveRedisOperations<K, V
new CloseSuppressingInvocationHandler(reactiveRedisConnection));
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForGeo()
*/
@Override
public ReactiveGeoOperations<K, V> opsForGeo() {
return opsForGeo(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForGeo(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, V1> ReactiveGeoOperations<K1, V1> opsForGeo(RedisSerializationContext<K1, V1> serializationContext) {
return new DefaultReactiveGeoOperations<>(this, serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForHash()
*/
@Override
public <HK, HV> ReactiveHashOperations<K, HK, HV> opsForHash() {
return opsForHash(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForHash(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, HK, HV> ReactiveHashOperations<K1, HK, HV> opsForHash(
RedisSerializationContext<K1, ?> serializationContext) {
return new DefaultReactiveHashOperations<>(this, serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForHyperLogLog()
*/
@Override
public ReactiveHyperLogLogOperations<K, V> opsForHyperLogLog() {
return opsForHyperLogLog(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForHyperLogLog(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, V1> ReactiveHyperLogLogOperations<K1, V1> opsForHyperLogLog(
RedisSerializationContext<K1, V1> serializationContext) {
return new DefaultReactiveHyperLogLogOperations<>(this, serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForList()
*/
@Override
public ReactiveListOperations<K, V> opsForList() {
return opsForList(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForList(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, V1> ReactiveListOperations<K1, V1> opsForList(RedisSerializationContext<K1, V1> serializationContext) {
return new DefaultReactiveListOperations<>(this, serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForSet()
*/
@Override
public ReactiveSetOperations<K, V> opsForSet() {
return opsForSet(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForSet(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, V1> ReactiveSetOperations<K1, V1> opsForSet(RedisSerializationContext<K1, V1> serializationContext) {
return new DefaultReactiveSetOperations<>(this, serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForValue()
*/
@Override
public ReactiveValueOperations<K, V> opsForValue() {
return opsForValue(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForValue(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, V1> ReactiveValueOperations<K1, V1> opsForValue(RedisSerializationContext<K1, V1> serializationContext) {
return new DefaultReactiveValueOperations<>(this, serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForZSet()
*/
@Override
public ReactiveZSetOperations<K, V> opsForZSet() {
return opsForZSet(serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#opsForZSet(org.springframework.data.redis.serializer.RedisSerializationContext)
*/
@Override
public <K1, V1> ReactiveZSetOperations<K1, V1> opsForZSet(RedisSerializationContext<K1, V1> serializationContext) {
return new DefaultReactiveZSetOperations<>(this, serializationContext);
}
/* (non-Javadoc)
* @see org.springframework.data.redis.core.ReactiveRedisOperations#serialization()
*/

View File

@@ -496,20 +496,55 @@ public interface RedisOperations<K, V> {
// -------------------------------------------------------------------------
// operation types
/**
* Returns the operations performed on simple values (or Strings in Redis terminology).
*
* @return value operations
*/
ValueOperations<K, V> opsForValue();
/**
* Returns the operations performed on simple values (or Strings in Redis terminology) bound to the given key.
* Returns the cluster specific operations interface.
*
* @param key Redis key
* @return value operations bound to the given key
* @return never {@literal null}.
* @since 1.7
*/
BoundValueOperations<K, V> boundValueOps(K key);
ClusterOperations<K, V> opsForCluster();
/**
* Returns geospatial specific operations interface.
*
* @return never {@literal null}.
* @since 1.8
*/
GeoOperations<K, V> opsForGeo();
/**
* Returns geospatial specific operations interface bound to the given key.
*
* @param key must not be {@literal null}.
* @return never {@literal null}.
* @since 1.8
*/
BoundGeoOperations<K, V> boundGeoOps(K key);
/**
*Returns the operations performed on hash values.
*
* @param <HK> hash key (or field) type
* @param <HV> hash value type
* @return hash operations
*/
<HK, HV> HashOperations<K, HK, HV> opsForHash();
/**
* Returns the operations performed on hash values bound to the given key.
* * @param <HK> hash key (or field) type
* @param <HV> hash value type
* @param key Redis key
* @return hash operations bound to the given key.
*/
<HK, HV> BoundHashOperations<K, HK, HV> boundHashOps(K key);
/**
* @return
* @since 1.5
*/
HyperLogLogOperations<K, V> opsForHyperLogLog();
/**
* Returns the operations performed on list values.
@@ -541,6 +576,21 @@ public interface RedisOperations<K, V> {
*/
BoundSetOperations<K, V> boundSetOps(K key);
/**
* Returns the operations performed on simple values (or Strings in Redis terminology).
*
* @return value operations
*/
ValueOperations<K, V> opsForValue();
/**
* Returns the operations performed on simple values (or Strings in Redis terminology) bound to the given key.
*
* @param key Redis key
* @return value operations bound to the given key
*/
BoundValueOperations<K, V> boundValueOps(K key);
/**
* Returns the operations performed on zset values (also known as sorted sets).
*
@@ -548,12 +598,6 @@ public interface RedisOperations<K, V> {
*/
ZSetOperations<K, V> opsForZSet();
/**
* @return
* @since 1.5
*/
HyperLogLogOperations<K, V> opsForHyperLogLog();
/**
* Returns the operations performed on zset values (also known as sorted sets) bound to the given key.
*
@@ -562,50 +606,6 @@ public interface RedisOperations<K, V> {
*/
BoundZSetOperations<K, V> boundZSetOps(K key);
/**
* Returns the operations performed on hash values.
*
* @param <HK> hash key (or field) type
* @param <HV> hash value type
* @return hash operations
*/
<HK, HV> HashOperations<K, HK, HV> opsForHash();
/**
* Returns the operations performed on hash values bound to the given key.
*
* @param <HK> hash key (or field) type
* @param <HV> hash value type
* @param key Redis key
* @return hash operations bound to the given key.
*/
<HK, HV> BoundHashOperations<K, HK, HV> boundHashOps(K key);
/**
* Returns geospatial specific operations interface.
*
* @return never {@literal null}.
* @since 1.8
*/
GeoOperations<K, V> opsForGeo();
/**
* Returns geospatial specific operations interface bound to the given key.
*
* @param key must not be {@literal null}.
* @return never {@literal null}.
* @since 1.8
*/
BoundGeoOperations<K, V> boundGeoOps(K key);
/**
* Returns the cluster specific operations interface.
*
* @return never {@literal null}.
* @since 1.7
*/
ClusterOperations<K, V> opsForCluster();
/**
* @return the key {@link RedisSerializer}.
*/

View File

@@ -1116,24 +1116,112 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#boundValueOps(java.lang.Object)
* @see org.springframework.data.redis.core.RedisOperations#killClient(java.lang.Object)
*/
@Override
public BoundValueOperations<K, V> boundValueOps(K key) {
return new DefaultBoundValueOperations<>(key, this);
public void killClient(final String host, final int port) {
execute((RedisCallback<Void>) connection -> {
connection.killClient(host, port);
return null;
});
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#opsForValue()
* @see org.springframework.data.redis.core.RedisOperations#getClientList()
*/
@Override
public ValueOperations<K, V> opsForValue() {
public List<RedisClientInfo> getClientList() {
return execute(RedisServerCommands::getClientList);
}
if (valueOps == null) {
valueOps = new DefaultValueOperations<>(this);
/*
* @see org.springframework.data.redis.core.RedisOperations#slaveOf(java.lang.String, int)
*/
@Override
public void slaveOf(final String host, final int port) {
execute((RedisCallback<Void>) connection -> {
connection.slaveOf(host, port);
return null;
});
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#slaveOfNoOne()
*/
@Override
public void slaveOfNoOne() {
execute((RedisCallback<Void>) connection -> {
connection.slaveOfNoOne();
return null;
});
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#opsForCluster()
*/
@Override
public ClusterOperations<K, V> opsForCluster() {
return new DefaultClusterOperations<>(this);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#opsForGeo()
*/
@Override
public GeoOperations<K, V> opsForGeo() {
if (geoOps == null) {
geoOps = new DefaultGeoOperations<>(this);
}
return valueOps;
return geoOps;
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#boundGeoOps(java.lang.Object)
*/
@Override
public BoundGeoOperations<K, V> boundGeoOps(K key) {
return new DefaultBoundGeoOperations<>(key, this);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#boundHashOps(java.lang.Object)
*/
@Override
public <HK, HV> BoundHashOperations<K, HK, HV> boundHashOps(K key) {
return new DefaultBoundHashOperations<>(key, this);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#opsForHash()
*/
@Override
public <HK, HV> HashOperations<K, HK, HV> opsForHash() {
return new DefaultHashOperations<>(this);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#opsForHyperLogLog()
*/
@Override
public HyperLogLogOperations<K, V> opsForHyperLogLog() {
if (hllOps == null) {
hllOps = new DefaultHyperLogLogOperations<>(this);
}
return hllOps;
}
/*
@@ -1180,6 +1268,28 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
return setOps;
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#boundValueOps(java.lang.Object)
*/
@Override
public BoundValueOperations<K, V> boundValueOps(K key) {
return new DefaultBoundValueOperations<>(key, this);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#opsForValue()
*/
@Override
public ValueOperations<K, V> opsForValue() {
if (valueOps == null) {
valueOps = new DefaultValueOperations<>(this);
}
return valueOps;
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#boundZSetOps(java.lang.Object)
@@ -1202,116 +1312,6 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
return zSetOps;
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#opsForGeo()
*/
@Override
public GeoOperations<K, V> opsForGeo() {
if (geoOps == null) {
geoOps = new DefaultGeoOperations<>(this);
}
return geoOps;
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#boundGeoOps(java.lang.Object)
*/
@Override
public BoundGeoOperations<K, V> boundGeoOps(K key) {
return new DefaultBoundGeoOperations<>(key, this);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#opsForHyperLogLog()
*/
@Override
public HyperLogLogOperations<K, V> opsForHyperLogLog() {
if (hllOps == null) {
hllOps = new DefaultHyperLogLogOperations<>(this);
}
return hllOps;
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#boundHashOps(java.lang.Object)
*/
@Override
public <HK, HV> BoundHashOperations<K, HK, HV> boundHashOps(K key) {
return new DefaultBoundHashOperations<>(key, this);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#opsForHash()
*/
@Override
public <HK, HV> HashOperations<K, HK, HV> opsForHash() {
return new DefaultHashOperations<>(this);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#opsForCluster()
*/
@Override
public ClusterOperations<K, V> opsForCluster() {
return new DefaultClusterOperations<>(this);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#killClient(java.lang.Object)
*/
@Override
public void killClient(final String host, final int port) {
execute((RedisCallback<Void>) connection -> {
connection.killClient(host, port);
return null;
});
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#getClientList()
*/
@Override
public List<RedisClientInfo> getClientList() {
return execute(RedisServerCommands::getClientList);
}
/*
* @see org.springframework.data.redis.core.RedisOperations#slaveOf(java.lang.String, int)
*/
@Override
public void slaveOf(final String host, final int port) {
execute((RedisCallback<Void>) connection -> {
connection.slaveOf(host, port);
return null;
});
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.RedisOperations#slaveOfNoOne()
*/
@Override
public void slaveOfNoOne() {
execute((RedisCallback<Void>) connection -> {
connection.slaveOfNoOne();
return null;
});
}
/**
* If set to {@code true} {@link RedisTemplate} will use {@literal MULTI...EXEC|DISCARD} to keep track of operations.
*