本文整理汇总了Java中com.google.common.cache.RemovalCause.SIZE属性的典型用法代码示例。如果您正苦于以下问题:Java RemovalCause.SIZE属性的具体用法?Java RemovalCause.SIZE怎么用?Java RemovalCause.SIZE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.common.cache.RemovalCause
的用法示例。
在下文中一共展示了RemovalCause.SIZE属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRemoval
@Override
public void onRemoval(RemovalNotification<CacheValue, NodeDocument> n) {
//If removed explicitly then we clear from L2
if (n.getCause() == RemovalCause.EXPLICIT
|| n.getCause() == RemovalCause.REPLACED) {
offHeapCache.invalidate(n.getKey());
}
//If removed because of size then we move it to
//L2
if (n.getCause() == RemovalCause.SIZE) {
NodeDocument doc = n.getValue();
if (doc != NodeDocument.NULL) {
offHeapCache.put(n.getKey(),
new NodeDocReference(n.getKey(), doc));
}
}
}
示例2: onRemoval
@Override
public void onRemoval(RemovalNotification<Object, Object> notification) {
if (notification.getCause() == RemovalCause.SIZE) {
if (evictionCounter % logInterval == 0) {
logger.log(LogLevel.INFO, "Cache entries evicted. In-memory cache of {}: Size{{}} MaxSize{{}}, {} {}", cacheId, cache.size(), maxSize, cache.stats(), EVICTION_MITIGATION_MESSAGE);
}
evictionCounter++;
}
}
示例3: onRemoval
/**
* Callback method for removal of items from the histories cache. Items removed from the cache need to be acked or failed
* according to the reason they were removed
*/
@Override
public void onRemoval(RemovalNotification<CVParticle, String> notification) {
// make sure the CVParticle object is removed from the history (even if removal was automatic!)
history.clear(notification.getKey(), notification.getValue());
if(notification.getCause() == RemovalCause.EXPIRED || notification.getCause() == RemovalCause.SIZE){
// item removed automatically --> fail the tuple
collector.fail(notification.getKey().getTuple());
}else{
// item removed explicitly --> ack the tuple
collector.ack(notification.getKey().getTuple());
}
}
示例4: onRemoval
@Override
public void onRemoval(RemovalNotification<BigInteger, ICursor> notification) {
if (notification.getCause() == RemovalCause.SIZE) {
notification.getValue().close();
}
}