Spring Infinispan - Setting expiry time for cached objects

冷暖自知 提交于 2019-12-08 13:50:37

问题


We are currently using below. It's quite old, but cannot upgrade to higher version now

`
  <dependency>
     <groupId>org.infinispan</groupId>
     <artifactId>infinispan-spring3</artifactId>
     <version>6.4.0.Final-redhat-4</version>
  </dependency>
  <dependency>
    <groupId>org.infinispan</groupId>
    <artifactId>infinispan-client-hotrod</artifactId>
    <version>6.4.0.Final-redhat-4</version>
  </dependency>
`

We have modified our code from something with a direct JDG implementation (as shown below) to SpringRemoteCacheManager in an XML based configuration file and are using Spring cache:advice to define cacheable, cahce-put, cache-evict methods.

See Current code where we have control to add expiry time. We want to do similar thing with Spring - Infinispan as well. With Spring - Infinispan we do not write any application code that puts/gets objects in/from cache as its handled by Spring annotations (@Cacheable / @CachePut) Appreciate if anyone can provide any pointers

RemoteCache<Object, Object> cache =  jdgRemoteCacheManager.getCache(cacheName);
cache.put(keyName, object, 15, TimeUnit.MINUTES);

回答1:


Unfortunately Spring Cache support doesn't provide such methods (see the Javadocs). So it seems the only way is to use the RemoteCache API provided by Infinispan.

Perhaps you could implement your own @Cacheable annotation and implement all the functionality you need. But that's a Spring question really...



来源:https://stackoverflow.com/questions/50397558/spring-infinispan-setting-expiry-time-for-cached-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!