INT-2799/2811 Redis Store Adapter Changes
INT-2799 Use StringRedisTemplate by default on both inbound and outbound store adapters. Use a RedisTemplate with String key serializers and JDK value serializers on the outbound store adapter if 'extract-payload-elements' is false. INT-2811 Remove the ability to configure serializers on the adapters. Use an external RedisTemplate for customized serialization strategies. INT-2811 Polishing (Review) Polishing and updated Reference Doc. polishing using setters instead of ctor args for key or keyExpression INT-2811 Polishing Improve message when handler not initialized. Add test for storing a simple value in a map.
This commit is contained in:
@@ -247,22 +247,6 @@ rt.setConnectionFactory(redisConnectionFactory);]]></programlisting>
|
||||
<listitem>
|
||||
<para><code>collection-type</code> - enumeration of the Collection types supported by this adapter. Supported Collections are: LIST, SET, ZSET, PROPERTIES, MAP </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><code>key-serializer</code> - reference to an instance of <code>org.springframework.data.redis.serializer.RedisSerializer</code>
|
||||
to be used while serializing keys </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><code>value-serializer</code> - reference to an instance of <code>org.springframework.data.redis.serializer.RedisSerializer</code>
|
||||
to be used while serializing values </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><code>hash-key-serializer</code> - reference to an instance of <code>org.springframework.data.redis.serializer.RedisSerializer</code>
|
||||
to be used while serializing hash keys </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><code>hash-value-serializer</code> - reference to an instance of <code>org.springframework.data.redis.serializer.RedisSerializer</code>
|
||||
to be used while serializing hash values </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><code>connection-factory</code> -
|
||||
reference to an instance of <classname>org.springframework.data.redis.connection.RedisConnectionFactory</classname> </para>
|
||||
@@ -278,6 +262,28 @@ rt.setConnectionFactory(redisConnectionFactory);]]></programlisting>
|
||||
<note>
|
||||
You cannot set both <code>redis-template</code> and <code>connection-factory</code>.
|
||||
</note>
|
||||
<important>
|
||||
By default, the adapter uses a <classname>StringRedisTemplate</classname>; this uses
|
||||
<classname>StringRedisSerializer</classname>s for keys, values, hash keys and hash values. If your
|
||||
Redis store contains objects that are serialized with other techniques, you must supply a
|
||||
<classname>RedisTemplate</classname> configured with appropriate serializers.
|
||||
For example, if the store is written to using a RedisStore Outbound Adapter that has its
|
||||
<code>extract-payload-elements</code> set to false, you must provide a
|
||||
<classname>RedisTemplate</classname> configured thus:
|
||||
<programlisting><![CDATA[<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="redisConnectionFactory"/>
|
||||
<property name="keySerializer">
|
||||
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
|
||||
</property>
|
||||
<property name="hashKeySerializer">
|
||||
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
|
||||
</property>
|
||||
</bean>]]></programlisting>
|
||||
<para>
|
||||
This uses String serializers for keys and hash keys and the default JDK Serialization serializers for
|
||||
values and hash values.
|
||||
</para>
|
||||
</important>
|
||||
<para>
|
||||
The example above is relatively simple and static since it has a literal value for the <code>key</code>.
|
||||
Sometimes, you may need to change the value of the key at runtime based on some condition.
|
||||
@@ -367,22 +373,6 @@ rt.setConnectionFactory(redisConnectionFactory);]]></programlisting>
|
||||
<listitem>
|
||||
<para><code>collection-type</code> - enumeration of the Collection types supported by this adapter. Supported Collections are: LIST, SET, ZSET, PROPERTIES, MAP </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><code>key-serializer</code> - reference to an instance of the <code>org.springframework.data.redis.serializer.RedisSerializer</code>
|
||||
to be used while serializing keys </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><code>value-serializer</code> - reference to an instance of the <code>org.springframework.data.redis.serializer.RedisSerializer</code>
|
||||
to be used while serializing values </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><code>hash-key-serializer</code> - reference to an instance of the <code>org.springframework.data.redis.serializer.RedisSerializer</code>
|
||||
to be used while serializing hash keys </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><code>hash-value-serializer</code> - reference to an instance of the <code>org.springframework.data.redis.serializer.RedisSerializer</code>
|
||||
to be used while serializing hash values </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><code>map-key-expression</code> - SpEL expression that returns the name of the key for entry being
|
||||
stored. Only applies if the <code>collection-type</code> is MAP or PROPERTIES and
|
||||
@@ -394,12 +384,25 @@ rt.setConnectionFactory(redisConnectionFactory);]]></programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para><code>redis-template</code> -
|
||||
reference to an instance of <classname>org.springframework.data.redis.core.RedisTemplate</classname>
|
||||
(NOTE: you can not have both redis-template and connection-factory set)</para>
|
||||
reference to an instance of <classname>org.springframework.data.redis.core.RedisTemplate</classname></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
and other attributes that are common across all other inbound adapters (e.g., 'channel').
|
||||
<note>
|
||||
You cannot set both <code>redis-template</code> and <code>connection-factory</code>.
|
||||
</note>
|
||||
</para>
|
||||
<important>
|
||||
By default, the adapter uses a <classname>StringRedisTemplate</classname>; this uses
|
||||
<classname>StringRedisSerializer</classname>s for keys, values, hash keys and hash values. However, if
|
||||
<code>extract-payload-elements</code> is set to false, a <classname>RedisTemplate</classname> using
|
||||
<classname>StringRedisSerializer</classname>s for keys and hash keys, and
|
||||
<classname>JdkSerializationRedisSerializer</classname>s for values and hash values will be used. With the JDK serializer, it is important
|
||||
to understand that java serialization is used for all values, regardless of whether the value
|
||||
is actually a collection or not. If you need more control over
|
||||
the serialization of values, you may want to consider providing your own
|
||||
<classname>RedisTemplate</classname> rather than relying upon these defaults.
|
||||
</important>
|
||||
<para>
|
||||
The example above is relatively simple and static since it has a literal values for the <code>key</code> and other attributes.
|
||||
Sometimes you may need to change the values dynamically at runtime based on some condition.
|
||||
|
||||
Reference in New Issue
Block a user