Spring Session Caching
To use Spring Session for Apache Geode for session state caching for apps with GemFire, follow these steps:
Make the following changes to the app:
- Replace the existing Spring Session
@EnableXXXHttpSession
annotation with@EnableGemFireHttpSession(maxInactiveIntervalInSeconds = N)
whereN
is in units of seconds. - Add the
spring-session-data-geode
andspring-data-geode
dependencies to the build. - Add beans to the Spring app configuration.
- Replace the existing Spring Session
Use gfsh to create a region on the cluster servers named
ClusteredSpringSessions
, when connected with a security role that can manage cluster data:
gfsh>create region --name=ClusteredSpringSessions --type=PARTITION_HEAP_LRU
Do not enable Tomcat session state caching as described in Enable Session State Caching. Mixing Tomcat session state caching with Spring Session caching is problematic.
The Session State Code Example demonstrates session state caching.
Find reference documentation at Spring Session.