-
1. Re: infinispan remote-cache expiration failure, but works in embedded mode
dan.berindei Feb 8, 2013 11:25 AM (in response to gibsosmat)1 of 1 people found this helpfulIn the REST server, the default values for the timeToLiveSeconds and maxIdleTimeSeconds parameters is -1, which means the entries never expire. If you set them to 0 explicitly, the REST server will use the defaults configured in the cache configuration.
This is a bit counter-intuitive, so I've created a feature request to change the defaults to 0: ISPN-2810. I've tentatively set the fix version to 5.3.0.Alpha1, but it is for backwards-compatibility reasons it may get fixed only in 6.0.0.
-
2. Re: infinispan remote-cache expiration failure, but works in embedded mode
gibsosmat Feb 9, 2013 7:03 AM (in response to dan.berindei)thanks for the reply, rest server was hosted to verify the behaviour.
my original problem is on hot-rod protocol and spring-cache-abstraction (3.1.x) using org.infinispan.client.hotrod.RemoteCacheManager
how can I set timeToLiveSeconds and maxIdleTimeSeconds to 0 from hotrod client by default, so that server side xml config is honored?
my spring xml config of hot-rod client
<cache:annotation-driven mode="aspectj"/> <bean id="remoteCacheManager" class="org.infinispan.client.hotrod.RemoteCacheManager"> <constructor-arg name="host" value="${infinispan.client.hotrod.host}" /> <constructor-arg name="port" value="${infinispan.client.hotrod.port}" /> </bean> <bean id="cacheManager" class="org.infinispan.spring.provider.SpringRemoteCacheManager"> <constructor-arg name="nativeCacheManager" ref="remoteCacheManager" /> </bean>
EDIT: added spring config
-
3. Re: infinispan remote-cache expiration failure, but works in embedded mode
gibsosmat Feb 10, 2013 12:05 AM (in response to gibsosmat)I think hotrod client is actually setting these values to 0 by default, but still cache didnt expire on server.
I executed the following test
@Test public void cacheTestSpring() throws Exception { String key = "my-key-1"; Long sleepTime = 15000L; cachedMethod(key); // this will put in the cache logger.info("----------sleeping for: {}", sleepTime); Thread.sleep(sleepTime); logger.info("---------------------result: {}", cachedMethod(key)); } @Cacheable("my-cache") private String cachedMethod(String key){ logger.info("cache miss for key: {}", key); return "my-value-"+ key.substring(7); }
from logs
[main] TRACE org.infinispan.client.hotrod.impl.RemoteCacheImpl - For key(my-key-1) returning null [main] INFO com.tests.CacheTest - cache miss for key: my-key-1 [main] TRACE org.infinispan.client.hotrod.impl.RemoteCacheImpl - About to add (K,V): (my-key-1, my-value-1) lifespanSecs:0, maxIdleSecs:0 ... [main] TRACE org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory - For server localhost/127.0.0.1:11222: active = 0; idle = 1 [main] INFO com.tests.CacheTest - ----------sleeping for: 15000 [main] TRACE o.s.c.aspectj.AnnotationCacheAspect - Computed cache key my-key-1 for operation CacheableOperation[private java.lang.String com.tests.CacheTest.cachedMethod(java.lang.String)] caches=[my-cache] | condition='' | key='' ... [main] TRACE org.infinispan.client.hotrod.impl.RemoteCacheImpl - For key(my-key-1) returning my-value-1 [main] INFO com.tests.CacheTest - ---------------------result: my-value-1
full log attached.
I also tried programatic cache by wiring cacheManager of spring abstraction.
@Test public void cacheTestBasic() throws Exception { Cache cache = cacheManager.getCache("my-cache"); String key = "my-key-2"; String value = "my-value-2"; Long sleepTime = 15000L; cache.put(key, value); logger.info("---------------------sleeping for: {}", sleepTime); Thread.sleep(sleepTime); ValueWrapper result = cache.get(key); if(result != null){ logger.info("---------------------result: {}", result.get()); } }
but still the 2nd call succeeded to get from cache. and logs show that idle times are set to 0.
-
4. Re: infinispan remote-cache expiration failure, but works in embedded mode
gibsosmat Feb 11, 2013 8:06 AM (in response to gibsosmat)one more observation.
I switched version to 5.2.1.Final server & client and the same config, test case is working as expected. i.e 2nd call dosent get it from cache.
but 5.2 server with 5.1.6 client, cache dosent expire. may be the client is sending the value -1 or somesort.
my problem is fixed by changing version. as I am just trying it out.
just for posterity I am leaving this question open.
-
5. Re: infinispan remote-cache expiration failure, but works in embedded mode
dan.berindei Feb 12, 2013 2:44 PM (in response to gibsosmat)Yes, this only works with HotRod protocol 1.2 (which is used when both the client and the server are 5.2.0+).
For reference, this is the issue in JIRA: https://issues.jboss.org/browse/ISPN-1293