public final class LeastRecentlyUsedCacheEvictor extends java.lang.Object implements CacheEvictor, java.util.Comparator<CacheSpan>
| Constructor and Description |
|---|
LeastRecentlyUsedCacheEvictor(long maxBytes) |
| Modifier and Type | Method and Description |
|---|---|
int |
compare(CacheSpan lhs,
CacheSpan rhs) |
void |
onCacheInitialized()
Called when cache has been initialized.
|
void |
onSpanAdded(Cache cache,
CacheSpan span)
Called when a
CacheSpan is added to the cache. |
void |
onSpanRemoved(Cache cache,
CacheSpan span)
Called when a
CacheSpan is removed from the cache. |
void |
onSpanTouched(Cache cache,
CacheSpan oldSpan,
CacheSpan newSpan)
Called when an existing
CacheSpan is accessed, causing it to be replaced. |
void |
onStartFile(Cache cache,
java.lang.String key,
long position,
long maxLength)
Called when a writer starts writing to the cache.
|
public LeastRecentlyUsedCacheEvictor(long maxBytes)
public void onCacheInitialized()
CacheEvictoronCacheInitialized in interface CacheEvictorpublic void onStartFile(Cache cache, java.lang.String key, long position, long maxLength)
CacheEvictoronStartFile in interface CacheEvictorcache - The source of the event.key - The key being written.position - The starting position of the data being written.maxLength - The maximum length of the data being written.public void onSpanAdded(Cache cache, CacheSpan span)
Cache.ListenerCacheSpan is added to the cache.onSpanAdded in interface Cache.Listenercache - The source of the event.span - The added CacheSpan.public void onSpanRemoved(Cache cache, CacheSpan span)
Cache.ListenerCacheSpan is removed from the cache.onSpanRemoved in interface Cache.Listenercache - The source of the event.span - The removed CacheSpan.public void onSpanTouched(Cache cache, CacheSpan oldSpan, CacheSpan newSpan)
Cache.ListenerCacheSpan is accessed, causing it to be replaced. The new
CacheSpan is guaranteed to represent the same data as the one it replaces, however
CacheSpan.file and CacheSpan.lastAccessTimestamp may have changed.
Note that for span replacement, Cache.Listener.onSpanAdded(Cache, CacheSpan) and
Cache.Listener.onSpanRemoved(Cache, CacheSpan) are not called in addition to this method.
onSpanTouched in interface Cache.Listenercache - The source of the event.oldSpan - The old CacheSpan, which has been removed from the cache.newSpan - The new CacheSpan, which has been added to the cache.