When I use spring-cache with aws elasticache, I get this error -
WARN c.g.code.ssm.spring.SSMCache - An error has ocurred for cache defaultCache and key module#1_8250
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.asyncStore(MemcachedClient.java:474) ~[elasticache-java-cluster-client.jar:na]
at net.spy.memcached.MemcachedClient.set(MemcachedClient.java:905) ~[elasticache-java-cluster-client.jar:na]
at net.spy.memcached.MemcachedClient.set(MemcachedClient.java:161) ~[elasticache-java-cluster-client.jar:na]
at com.google.code.ssm.providers.elasticache.MemcacheClientWrapper.set(MemcacheClientWrapper.java:274) ~[aws-elasticache-provider.jar:na]
at com.google.code.ssm.CacheImpl.set(CacheImpl.java:285) ~[simple-spring-memcached.jar:na]
at com.google.code.ssm.CacheImpl.set(CacheImpl.java:128) ~[simple-spring-memcached.jar:na]
at com.google.code.ssm.spring.SSMCache.put(SSMCache.java:159) ~[spring-cache.jar:na]
My config is as follows-
<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>
The same config is working when I access memcache directly (using get and set methods). It just does not work for spring-cache (@Cacheable) annotations.
NOTE: the DefaultAddressProvider here is just a fallback. I have a bean defined in java code which uses the config file for autodiscovery.
My usage is :
value = "defaultCache",
key = "#accountIdStr + #allArgs + #id") public @ResponseBody Object getDataFor(final HttpServletRequest request, final HttpServletResponse response, @PathVariable(URLConstants.ACCOUNT_ID_STR) final String accountIdStr, final @CustomArgumentAnnotation CustomArgument allArgs, final @RequestParam(value = URLConstants.QueryParams.ID_STR, required = true, defaultValue = "1") String id) { }I have ensured that the security group has the memcache port specified in Inbound and I am running my code in EC2.
--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-meme...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at http://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-meme...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at http://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-meme...@googlegroups.com.
//setup memcache
final MemcachedClient memcache = new MemcachedClient(new InetSocketAddress(memcacheClusterEndPoint, memcacheClusterPort));
//get from memcache
final Future<Object> f = memcache.asyncGet(userId);
//set to memcache
memcache.set(userId, 3600, newMemObj); //where newMemObj is of type MemcacheNotificationObject
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at http://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-meme...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at http://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-meme...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at http://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-meme...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at http://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at http://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.