You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For additional information on how to create a `RedisConnectionFactory`, see the Spring Data Redis Reference.
171
+
172
+
[[api-redissessionrepository-config]]
173
+
=== Using `@EnableRedisHttpSession`
174
+
175
+
In a web environment, the simplest way to create a new `RedisSessionRepository` is to use `@EnableRedisHttpSession`.
176
+
You can find complete example usage in the xref:samples.adoc#samples[Samples and Guides (Start Here)].
177
+
You can use the following attributes to customize the configuration:
178
+
179
+
enableIndexingAndEvents
180
+
* *enableIndexingAndEvents*: Whether to use a `RedisIndexedSessionRepository` instead of a `RedisSessionRepository`. The default is `false`.
181
+
* *maxInactiveIntervalInSeconds*: The amount of time before the session expires, in seconds.
182
+
* *redisNamespace*: Allows configuring an application specific namespace for the sessions. Redis keys and channel IDs start with the prefix of `<redisNamespace>:`.
183
+
* *flushMode*: Allows specifying when data is written to Redis. The default is only when `save` is invoked on `SessionRepository`.
184
+
A value of `FlushMode.IMMEDIATE` writes to Redis as soon as possible.
185
+
186
+
==== Custom `RedisSerializer`
187
+
188
+
You can customize the serialization by creating a bean named `springSessionDefaultRedisSerializer` that implements `RedisSerializer<Object>`.
189
+
190
+
[[api-redissessionrepository-cli]]
191
+
=== Viewing the Session in Redis
192
+
193
+
After https://redis.io/topics/quickstart[installing redis-cli], you can inspect the values in Redis https://redis.io/commands#hash[using the redis-cli].
194
+
For example, you can enter the following command into a terminal window:
For additional information on how to create a `RedisConnectionFactory`, see the Spring Data Redis Reference.
171
243
172
244
[[api-redisindexedsessionrepository-config]]
173
-
=== Using `@EnableRedisHttpSession`
245
+
=== Using `@EnableRedisHttpSession(enableIndexingAndEvents = true)`
174
246
175
-
In a web environment, the simplest way to create a new `RedisIndexedSessionRepository` is to use `@EnableRedisHttpSession`.
247
+
In a web environment, the simplest way to create a new `RedisIndexedSessionRepository` is to use `@EnableRedisHttpSession(enableIndexingAndEvents = true)`.
176
248
You can find complete example usage in the xref:samples.adoc#samples[Samples and Guides (Start Here)].
177
249
You can use the following attributes to customize the configuration:
178
250
251
+
* *enableIndexingAndEvents*: Whether to use a `RedisIndexedSessionRepository` instead of a `RedisSessionRepository`. The default is `false`.
179
252
* *maxInactiveIntervalInSeconds*: The amount of time before the session expires, in seconds.
180
253
* *redisNamespace*: Allows configuring an application specific namespace for the sessions. Redis keys and channel IDs start with the prefix of `<redisNamespace>:`.
181
254
* *flushMode*: Allows specifying when data is written to Redis. The default is only when `save` is invoked on `SessionRepository`.
@@ -335,7 +408,7 @@ redis-cli config set notify-keyspace-events Egx
335
408
----
336
409
====
337
410
338
-
If you use `@EnableRedisHttpSession`, managing the `SessionMessageListener` and enabling the necessary Redis Keyspace events is done automatically.
411
+
If you use `@EnableRedisHttpSession(enableIndexingAndEvents = true)`, managing the `SessionMessageListener` and enabling the necessary Redis Keyspace events is done automatically.
339
412
However, in a secured Redis enviornment, the config command is disabled.
340
413
This means that Spring Session cannot configure Redis Keyspace events for you.
341
414
To disable the automatic configuration, add `ConfigureRedisAction.NO_OP` as a bean.
Copy file name to clipboardExpand all lines: spring-session-docs/modules/ROOT/pages/http-session.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -235,7 +235,7 @@ To use this support, you need to:
235
235
* Configure `SessionEventHttpSessionListenerAdapter` as a Spring bean.
236
236
* Inject every `HttpSessionListener` into the `SessionEventHttpSessionListenerAdapter`
237
237
238
-
If you use the configuration support documented in <<httpsession-redis,`HttpSession` with Redis>>, all you need to do is register every `HttpSessionListener` as a bean.
238
+
If you use the Redis support with `enableIndexingAndEvents` set to `true`, `@EnableRedisHttpSession(enableIndexingAndEvents = true)`, all you need to do is register every `HttpSessionListener` as a bean.
239
239
For example, assume you want to support Spring Security's concurrency control and need to use `HttpSessionEventPublisher`. In that case, you can add `HttpSessionEventPublisher` as a bean.
240
240
In Java configuration, this might look like the following:
0 commit comments