本文整理汇总了Java中org.jivesoftware.util.cache.CacheFactory.getMaxCacheLifetime方法的典型用法代码示例。如果您正苦于以下问题:Java CacheFactory.getMaxCacheLifetime方法的具体用法?Java CacheFactory.getMaxCacheLifetime怎么用?Java CacheFactory.getMaxCacheLifetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.util.cache.CacheFactory
的用法示例。
在下文中一共展示了CacheFactory.getMaxCacheLifetime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCache
import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
public Cache createCache(String name) {
// Check if cluster is being started up
while (state == State.starting) {
// Wait until cluster is fully started (or failed)
try {
Thread.sleep(250);
}
catch (InterruptedException e) {
// Ignore
}
}
if (state == State.stopped) {
throw new IllegalStateException("Cannot create clustered cache when not in a cluster");
}
// Determine the time to live. Note that in Hazelcast 0 means "forever", not -1
final long openfireLifetimeInMilliseconds = CacheFactory.getMaxCacheLifetime(name);
final int hazelcastLifetimeInSeconds = openfireLifetimeInMilliseconds < 0 ? 0 : (int) (openfireLifetimeInMilliseconds / 1000);
// Determine the max cache size. Note that in Hazelcast the max cache size must be positive
final long openfireMaxCacheSize = CacheFactory.getMaxCacheSize(name);
final int hazelcastMaxCacheSize = openfireMaxCacheSize < 0 ? Integer.MAX_VALUE : (int) openfireMaxCacheSize;
final MapConfig mapConfig = hazelcast.getConfig().getMapConfig(name);
mapConfig.setTimeToLiveSeconds(hazelcastLifetimeInSeconds);
mapConfig.setMaxSizeConfig(new MaxSizeConfig(hazelcastMaxCacheSize, MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE));
return new ClusteredCache(name, hazelcast.getMap(name), hazelcastLifetimeInSeconds);
}
示例2: getMaxLifetime
import org.jivesoftware.util.cache.CacheFactory; //导入方法依赖的package包/类
public long getMaxLifetime() {
return CacheFactory.getMaxCacheLifetime(getName());
}