Spring Infinispan-设置缓存对象的到期时间 [英] Spring Infinispan - Setting expiry time for cached objects

查看:279
本文介绍了Spring Infinispan-设置缓存对象的到期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前在下面使用。它已经很旧了,但是现在不能升级到更高版本

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>
`

我们已经通过直接JDG实现对代码进行了修改(如下所示) )添加到基于XML的配置文件中的SpringRemoteCacheManager,并使用Spring cache:advice定义可缓存的,cahce-put,cache-evct方法。

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.

请参阅当前代码控制以添加到期时间。我们也想用Spring-Infinispan做类似的事情。使用Spring-Infinispan时,我们不会编写任何将对象放入缓存或从缓存中获取对象的应用程序代码,这些代码由Spring注释(@Cacheable / @CachePut)处理。
如果有人可以提供任何指针,则感谢

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);


推荐答案

不幸的是,Spring Cache支持不提供此类方法(请参见 Javadocs )。因此,似乎唯一的方法是使用Infinispan提供的 RemoteCache API。

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.

也许您可以实现自己的 @Cacheable 批注并实现所需的所有功能。但这确实是一个春季问题...

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

这篇关于Spring Infinispan-设置缓存对象的到期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆