本文整理汇总了Java中com.google.common.cache.RemovalCause.EXPLICIT属性的典型用法代码示例。如果您正苦于以下问题:Java RemovalCause.EXPLICIT属性的具体用法?Java RemovalCause.EXPLICIT怎么用?Java RemovalCause.EXPLICIT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.common.cache.RemovalCause
的用法示例。
在下文中一共展示了RemovalCause.EXPLICIT属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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<Writable, T> note) {
// System.err.println("S0 Cache: " + activeKey + " " + note.getKey() + " " + note.getCause() + " " + cache.size());
if (!(note.wasEvicted() || note.getCause() == RemovalCause.EXPLICIT)) {
return;
}
if (activeKey != null && activeKey.equals(note.getKey())) {
return;
}
try {
// System.err.println(" s0emit: " + note.getCause() + " " + note.getKey() + " " + note.getValue());
// Emit the record.
collector.emit(new FValues(note.getKey(), note.getValue()));
} catch (Throwable e) {
lastThrown = e;
}
}
示例3: onRemoval
@Override
public void onRemoval(RemovalNotification<String, CachedOffer> notification) {
if (notification.getCause() == RemovalCause.EXPLICIT) {
return;
}
LOG.debug("Cache removal for {} due to {}", notification.getKey(), notification.getCause());
synchronized (offerCache) {
if (notification.getValue().offerState == OfferState.AVAILABLE) {
declineOffer(notification.getValue());
} else {
notification.getValue().expire();
}
}
}
示例4: onRemoval
@Override
public void onRemoval(RemovalNotification<FileInfo, MuxedFile> notification) {
if (notification.getCause() != RemovalCause.EXPLICIT) {
MuxedFile muxedFile = notification.getValue();
// This is racy, at worst we will re-trigger muxing for unlucky files being re-opened
if (!openMuxFiles.containsValue(muxedFile)) {
muxFiles.remove(muxedFile.getInfo(), muxedFile.getMuxer());
logger.info("Expired {}: {} deleted = {}", notification.getCause(), muxedFile, safeDelete(muxedFile));
} else {
logger.warn("BUG: Expired {}: {}, but is still open!", notification.getCause(), muxedFile);
}
}
}
示例5: onRemoval
@Override
public void onRemoval(final RemovalNotification<ChunkCoordIntPair, NBTTagCompound> notification) {
try {
// Only flush the entry if it was invalidated. Any entry could
// be updated prior to it being written by an IO thread so we
// want to avoid unnecessary writes.
if (notification.getCause() == RemovalCause.EXPLICIT)
AnvilChunkLoader.this.writeChunkNBTTags(notification.getKey(), notification.getValue());
} catch (final Exception e) {
e.printStackTrace();
}
}
示例6: onRemoval
@Override
public void onRemoval(RemovalNotification<Writable, T> note) {
// System.err.println("S1 Cache: " + activeKey + " " + note.getKey() + " " + note.getCause() + " " + cache.size());
if (!(note.wasEvicted() || note.getCause() == RemovalCause.EXPLICIT)) {
return;
}
if (activeKey != null && activeKey.equals(note.getKey())) {
return;
}
try {
// Determine if the current value is in the backlog or the prefetch.
T cur;
if (!stateBacklog.containsKey(note.getKey())) {
// Pull the values in from the prefetch.
runPrefetch();
}
cur = stateBacklog.remove(note.getKey());
// System.err.println("stateBacklogged: k=<" + note.getKey() + "> v=" + cur);
// Apply the update.
cur = storeAgg.combine(cur, note.getValue());
// Move things to the writeAhead.
writeAhead.put(note.getKey(), cur);
// Emit the result.
collector.emit(new FValues(note.getKey(), cur));
} catch (Throwable e) {
lastThrown = e;
}
}