标签:span pos end conf trie archive ack lookup life
背景:基于wildfly 10,我们使用内置的infinispan缓存,本次实例只适用于同一jvm下,不能进行分布式使用。
(转载请注明来源:cnblogs coder-fang)
<cache-container name="appcache" default-cache="session" statistics-enabled="false"/>
<!-- for cache--> <dependency> <groupId>org.wildfly</groupId> <artifactId>wildfly-clustering-infinispan-extension</artifactId> <version>10.0.0.Final</version> <scope>provided</scope> </dependency>
<plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <finalName>${project.build.finalName}</finalName> <archive> <manifestEntries>
<!-- infinispan depend --> <Dependencies>org.infinispan, org.infinispan.commons, org.jboss.as.clustering.infinispan export</Dependencies> </manifestEntries> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <appendAssemblyId>false</appendAssemblyId> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin>
@Resource(lookup="java:jboss/infinispan/container/appcache")
EmbeddedCacheManager container;
@PostConstruct public void init() { container.defineConfiguration("session",new ConfigurationBuilder() .expiration().lifespan(6000) .build()); cache=container.getCache(); logger.debug("cache name:"+cache.getName()); logger.debug("cache lifespan:"+cache.getCacheConfiguration().expiration().lifespan()); logger.info("init----"); }
注:如上所示,当put value进入缓存后,6秒之后自动删除此value
总结:如果不设置相关过期时间,value只能通过remove删除,或wildfly停止后,所有缓存也将清空。
J2EE之wildfly 实践9 -- 使用infinispan 过期缓存
标签:span pos end conf trie archive ack lookup life
原文地址:http://www.cnblogs.com/coder-fang/p/7871842.html