在我的Spring应用程序中,我使用以下缓存(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>
在此缓存中,我存储了对我的API后端的访问票证。一切都可以与单个节点Tomcat8完美配合。但是,当我尝试在我的AWS集群中的2个或更多实例与Load Balancer(ELB)和N Tomcats(在EC2实例上)一起使用时,我遇到了一个问题,即每个节点都使用自己的
statelessTicketCache
实例进行操作。我需要在整个群集中复制此
ehcache statelessTicketCache
。可能吗 ?如果是这样,您可以为此提供一个示例配置吗?更新
我认为,我将退出
Ehcache
解决方案,并尝试使用statelessTicketCache
(Redis引擎上的Redis
)配置AWS Elastic cache
,并使用Spring CAS Stateless Ticket Cache Redis的以下实现https://github.com/vnomics/spring-stateless-ticket-cache-redis 最佳答案
我已经从Ehcache解决方案中移出,并使用Spring CAS Stateless Ticket Cache Redis的以下实现https://github.com/vnomics/spring-stateless-ticket-cache-redis使用Redis(Redis引擎上的AWS弹性缓存)配置statelessTicketCache
。
现在,一切正常。