2016-08-05 51 views
0

我使用Infinispan的,但重新启动我的Wildfly时不能保持高速缓存中的文件存储Infinispan的跟不上缓存文件Wildfly 10

@Resource(lookup = "java:jboss/infinispan/container/server") 
private EmbeddedCacheManager manager; 

public String test() { 
this.cache.put(UUID.randomUUID().toString(), new Date()); 
    this.cache.put(UUID.randomUUID().toString(), new Date()); 
    this.cache.put(UUID.randomUUID().toString(), new Date()); 
    this.cache.put(UUID.randomUUID().toString(), new Date()); 
    this.cache.put(UUID.randomUUID().toString(), new Date()); 
} 

@PostConstruct 
protected void init() { 
    this.manager.start(); 
    this.cache = this.manager.getCache(); 
} 

这是我standalone.xml

<cache-container name="server" default-cache="default" module="org.wildfly.clustering.web.infinispan"> 
    <local-cache name="default"> 
     <transaction mode="BATCH"/> 
     <file-store relative-to="jboss.server.data.dir" path="infinispan" passivation="false" purge="false"/> 
    </local-cache> 
</cache-container> 
+0

不能说我的头顶,但你不应该启动管理器,因为它已经开始注入。你可以尝试删除它吗? –

回答

1

的解决方案:直接注入缓存。这可确保您的缓存使用的缓存配置在您需要时安装。此外,WildFly将自动处理缓存及其依赖项的生命周期。

例如

@Resource(lookup = "java:jboss/infinispan/cache/server/default") 
private Cache<UUID, Date> cache; 

我还建议直接使用UUID类型,而不是字符串,因为这些将更有效地序列化。

相关问题