In my Spring application I use a following cache(ehcache
):
<bean id="statelessTicketCache"
class="org.springframework.security.cas.authentication.EhCacheBasedTicketCache">
<property name="cache">
<bean id="ehcache" class="net.sf.ehcache.Cache" init-method="initialise"
destroy-method="dispose">
<constructor-arg value="casTickets" />
<constructor-arg value="0" />
<constructor-arg value="true" />
<constructor-arg value="false" />
<constructor-arg value="3600" />
<constructor-arg value="900" />
<property name="cacheManager" ref="cacheManager" />
</bean>
</property>
</bean>
In this cache I'm storing access tickets to my API back end. Everything works perfectly with a single node Tomcat8. But when I try to use 2 or more instances in my AWS cluster with Load Balancer(ELB) and N Tomcats(on EC2 instances) I ran into the issue that each node operates with own instance of statelessTicketCache
.
I need to replicate this ehcache statelessTicketCache
across my cluster. Is it possible ? If so, could you please provide a sample configuration for this ?
UPDATED
I think, I'll move out from the Ehcache
solution and will try to configure statelessTicketCache
with Redis
(AWS Elastic cache
on Redis engine) and use a following implementation https://github.com/vnomics/spring-stateless-ticket-cache-redis of Spring CAS Stateless Ticket Cache Redis