"client not initialized" 将 SSMCache 与 AWS elasticache 自动发现结合使用时出错
"client not initialized" error when using SSMCache with AWS elasticache autodiscovery
我正在将 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]
我正在使用没有 spring 缓存的相同内存缓存,它工作正常。仅当我使用 spring 缓存时才会出现此错误。
我已验证安全组指定了入站端口,我是 运行 我在 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>
显示您的配置和使用情况。
看来您没有定义 defaultCache 或在没有设置 'value' 参数的情况下使用 Cacheable。
我正在将 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]
我正在使用没有 spring 缓存的相同内存缓存,它工作正常。仅当我使用 spring 缓存时才会出现此错误。
我已验证安全组指定了入站端口,我是 运行 我在 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>
显示您的配置和使用情况。
看来您没有定义 defaultCache 或在没有设置 'value' 参数的情况下使用 Cacheable。