gpt4 book ai didi

spring - AWS ElastiCache 与 Spring

转载 作者:行者123 更新时间:2023-12-02 05:26:26 24 4
gpt4 key购买 nike

我正在尝试在使用 Spring 3.0 构建的应用程序中使用 elasticache

谁能帮忙配置一下吗?

最佳答案

找到解决方案 - 配置与 memcached 配置相同。

  1. pom.xml中添加以下内容
<小时/>
    <dependency>
<groupId>com.google.code.simple-spring-memcached</groupId>
<artifactId>spring-cache</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>com.google.code.simple-spring-memcached</groupId>
<artifactId>xmemcached-provider</artifactId>
<version>3.3.0</version>
</dependency>
<小时/>
  1. dispatcher-servlet.xml 中添加以下内容
<小时/>

<bean name="memcacheManager" class="com.google.code.ssm.spring.SSMCacheManager">
<property name="caches">
<set>
<bean class="com.google.code.ssm.spring.SSMCache">
<constructor-arg name="cache" index="0" ref="defaultCache"/>
<!-- 3 days -->
<constructor-arg name="expiration" index="1" value="259200"/>
<!-- @CacheEvict(..., "allEntries" = true) doesn't work -->
<constructor-arg name="allowClear" index="2" value="true"/>
</bean>
</set>
</property>

</bean>

<bean name="defaultCache" class="com.google.code.ssm.CacheFactory">
<property name="cacheName" value="defaultCache"/>
<property name="cacheClientFactory">
<bean name="cacheClientFactory" class="com.google.code.ssm.providers.xmemcached.MemcacheClientFactoryImpl"/>
</property>
<property name="addressProvider">
<bean class="com.google.code.ssm.config.DefaultAddressProvider">
<property name="address" value="xxx.yyy.cache.amazonaws.com:11211"/>
</bean>
</property>
<property name="configuration">
<bean class="com.google.code.ssm.providers.CacheConfiguration">
<property name="consistentHashing" value="true"/>
</bean>
</property>
</bean>
<小时/>

其中命名空间如下:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache-3.1.xsd">

关于spring - AWS ElastiCache 与 Spring,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21338270/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com