【问题标题】:Spring, Tomcat 8 Ehcache replication across AWS cluster(on EC2 instanse)Spring,Tomcat 8 Ehcache 跨 AWS 集群复制(在 EC2 实例上)
【发布时间】: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


    【解决方案1】:

    我已经从 Ehcache 解决方案中移出,并使用 Redis(Redis 引擎上的 AWS 弹性缓存)配置了 statelessTicketCache,并使用 Spring CAS Stateless Ticket Cache Redis 的以下实现 https://github.com/vnomics/spring-stateless-ticket-cache-redis

    现在,一切正常。

    【讨论】:

      猜你喜欢
      • 2021-03-31
      • 2021-12-02
      • 1970-01-01
      • 2023-03-17
      • 2016-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多