本文整理汇总了Java中net.jodah.expiringmap.ExpiringMap.ExpirationPolicy方法的典型用法代码示例。如果您正苦于以下问题:Java ExpiringMap.ExpirationPolicy方法的具体用法?Java ExpiringMap.ExpirationPolicy怎么用?Java ExpiringMap.ExpirationPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.jodah.expiringmap.ExpiringMap
的用法示例。
在下文中一共展示了ExpiringMap.ExpirationPolicy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put
import net.jodah.expiringmap.ExpiringMap; //导入方法依赖的package包/类
/**
* Puts given value into the cache with nested key of {@code firstKey}.{@code key}<br>
*
* @param firstKey The first key of the cache
* @param key The key
* @param value The value
* @param duration The duration
* @param unit The time unit for the duration
* @param removalListeners The listeners when the value is removed from the cache
* @return The result
*/
public boolean put(F firstKey, K key, V value,
ExpiringMap.ExpirationPolicy policy, long duration, TimeUnit unit,
Consumer<V>... removalListeners) {
if(firstKey == null || key == null || value == null) return false;
ExpiringMap<K, V> expiringMap = handle.getIfPresent(firstKey);
if(expiringMap == null) {
expiringMap = buildExpiringMap();
}
if(duration == -1 || unit == null || policy == null) {
expiringMap.put(key, value);
}
else {
expiringMap.put(key, value, policy, duration, unit);
}
handle.put(firstKey, expiringMap);
removalListenerMap.put(key, Arrays.asList(removalListeners));
return true;
}
示例2: set
import net.jodah.expiringmap.ExpiringMap; //导入方法依赖的package包/类
public void set(Object value, ExpiringMap.ExpirationPolicy policy, long duration, TimeUnit unit, Consumer... removalListeners) {
this.set(value.getClass().getName(), value, policy, duration, unit, removalListeners);
}