在我使用了以下缓存(ehcache
)我的Spring应用程序:春天,整个AWS集群的Tomcat 8的Ehcache复制(在EC2上instanse)
<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 Tomcats(在EC2实例上)中使用2个或更多实例时,我遇到了每个节点都使用statelessTicketCache
自己的实例运行的问题。
我需要在我的群集中复制此ehcache statelessTicketCache
。可能吗 ?如果是这样,您能否为此提供一个示例配置?
修订
我想,我会从Ehcache
解决迁出,并会尝试配置statelessTicketCache
与Redis
(AWS Elastic cache
对Redis的引擎),并使用以下实现春CAS无国籍票据缓存的Redis的https://github.com/vnomics/spring-stateless-ticket-cache-redis