public final class LeastRecentlyUsedCacheEvictor extends Object implements CacheEvictor, 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 beeen 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,
String key,
long position,
long maxLength)
Called when a writer starts writing to the cache.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public LeastRecentlyUsedCacheEvictor(long maxBytes)
public void onCacheInitialized()
CacheEvictor
onCacheInitialized
in interface CacheEvictor
public void onStartFile(Cache cache, String key, long position, long maxLength)
CacheEvictor
onStartFile
in interface CacheEvictor
cache
- 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.Listener
CacheSpan
is added to the cache.onSpanAdded
in interface Cache.Listener
cache
- The source of the event.span
- The added CacheSpan
.public void onSpanRemoved(Cache cache, CacheSpan span)
Cache.Listener
CacheSpan
is removed from the cache.onSpanRemoved
in interface Cache.Listener
cache
- The source of the event.span
- The removed CacheSpan
.public void onSpanTouched(Cache cache, CacheSpan oldSpan, CacheSpan newSpan)
Cache.Listener
CacheSpan
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.Listener
cache
- 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.public int compare(CacheSpan lhs, CacheSpan rhs)
compare
in interface Comparator<CacheSpan>