infinispan,通过传递缓存配置名称获取缓存管理器
infinispan, get cachemanager by passing cache configuration name
我有这个infinispan.xml配置:
<infinispan>
<cache-container default-cache="dist-sync">
<transport/>
<local-cache name="local">
<expiration lifespan="-1" max-idle="5000" />
</local-cache>
<invalidation-cache name="invalidation" mode="SYNC"/>
<replicated-cache name="repl-sync" mode="SYNC"/>
<distributed-cache name="dist-sync" mode="SYNC"/>
</cache-container>
</infinispan>
如何使用缓存名称配置 local 而不是默认缓存 (dist-sync)
来实例化 DefaultCacheManager
像这样:
DefaultCacheManager cacheManager = new DefaultCacheManager("infinispan.xml");
Cache<K, V> cache = cacheManager.getCache("local");
文档中的更多信息:https://infinispan.org/docs/stable/titles/configuring/configuring.html#cache_modes
附带说明,DefaultCacheManager.getCache()
returns 名称在 default-cache
属性中定义的缓存 (<cache-container default-cache="dist-sync">
)
我有这个infinispan.xml配置:
<infinispan>
<cache-container default-cache="dist-sync">
<transport/>
<local-cache name="local">
<expiration lifespan="-1" max-idle="5000" />
</local-cache>
<invalidation-cache name="invalidation" mode="SYNC"/>
<replicated-cache name="repl-sync" mode="SYNC"/>
<distributed-cache name="dist-sync" mode="SYNC"/>
</cache-container>
</infinispan>
如何使用缓存名称配置 local 而不是默认缓存 (dist-sync)
来实例化 DefaultCacheManager像这样:
DefaultCacheManager cacheManager = new DefaultCacheManager("infinispan.xml");
Cache<K, V> cache = cacheManager.getCache("local");
文档中的更多信息:https://infinispan.org/docs/stable/titles/configuring/configuring.html#cache_modes
附带说明,DefaultCacheManager.getCache()
returns 名称在 default-cache
属性中定义的缓存 (<cache-container default-cache="dist-sync">
)