0

我正在将 Spring 缓存与 AWS elasticache 提供程序一起使用。我收到这个警告:

WARN c.g.code.ssm.spring.SSMCache - An error has occurred for cache defaultCache and key 

java.lang.IllegalStateException: Client is not initialized
    at net.spy.memcached.MemcachedClient.checkState(MemcachedClient.java:1623) ~[elasticache-java-cluster-client.jar:na]
    at net.spy.memcached.MemcachedClient.enqueueOperation(MemcachedClient.java:1617) ~[elasticache-java-cluster-client.jar:na]
    at net.spy.memcached.MemcachedClient.asyncGet(MemcachedClient.java:1013) ~[elasticache-java-cluster-client.jar:na]
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1235) ~[elasticache-java-cluster-client.jar:na]
    at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:1256) ~[elasticache-java-cluster-client.jar:na]
    at com.google.code.ssm.providers.elasticache.MemcacheClientWrapper.get(MemcacheClientWrapper.java:147) ~[aws-elasticache-provider.jar:na]
    at com.google.code.ssm.CacheImpl.get(CacheImpl.java:271) ~[simple-spring-memcached.jar:na]
    at com.google.code.ssm.CacheImpl.get(CacheImpl.java:106) ~[simple-spring-memcached.jar:na]
    at com.google.code.ssm.spring.SSMCache.getValue(SSMCache.java:226) [spring-cache.jar:na]
    at com.google.code.ssm.spring.SSMCache.get(SSMCache.java:100) [spring-cache.jar:na]

我正在使用没有弹簧缓存的相同内存缓存,它工作正常。仅当我使用弹簧缓存时才会出现此错误。

我已验证安全组已指定入站端口,并且我正在 EC2 上运行我的代码。

更新 1:

添加我的配置 -

<bean name="cacheManager" 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="defaultMemcachedClient" />
                            <!-- 5 minutes -->
                            <constructor-arg name="expiration" index="1" value="3600" />
                            <!-- @CacheEvict(..., "allEntries" = true) won't work because allowClear is false, 
                            so we won't flush accidentally all entries from memcached instance -->
                            <constructor-arg name="allowClear" index="2" value="false" />
                    </bean>
            </set>
    </property>
    </bean>

    <bean name="defaultMemcachedClient" class="com.google.code.ssm.CacheFactory">
            <property name="cacheName" value="defaultCache" />
    <property name="cacheClientFactory">
            <bean name="cacheClientFactory" class="com.google.code.ssm.providers.elasticache.MemcacheClientFactoryImpl" />
    </property>
            <property name="addressProvider">
            <bean class="com.google.code.ssm.config.DefaultAddressProvider">
                    <property name="address" value="127.0.0.1:11211" />
            </bean>
    </property>
    <property name="configuration">
            <bean class="com.google.code.ssm.providers.elasticache.ElastiCacheConfiguration">
                    <property name="consistentHashing" value="true" />
                    <property name="clientMode" value="#{T(net.spy.memcached.ClientMode).Dynamic}" />
            </bean>
    </property>
    </bean>
4

1 回答 1

0

显示您的配置和使用情况。

它接缝你没有定义 defaultCache 或使用 Cacheable 没有设置“值”参数。

于 2015-06-15T05:19:26.007 回答