【发布时间】:2016-02-09 20:40:06
【问题描述】:
在我的 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 集群中使用负载均衡器(ELB)和 N Tomcat(在 EC2 实例上)中使用 2 个或更多实例时,我遇到了每个节点都使用自己的 statelessTicketCache 实例运行的问题。
我需要在我的集群中复制这个ehcache statelessTicketCache。可能吗 ?如果是这样,您能否为此提供一个示例配置?
更新
我想,我会退出 Ehcache 解决方案,并尝试使用 Redis(在 Redis 引擎上配置 AWS Elastic cache)配置 statelessTicketCache,并使用 Spring CAS Stateless Ticket 的以下实现 https://github.com/vnomics/spring-stateless-ticket-cache-redis缓存 Redis
【问题讨论】:
标签: spring tomcat amazon-web-services replication ehcache