Package org.cache2k.core.eviction
Interface Eviction
-
- All Superinterfaces:
NeedsClose
- All Known Implementing Classes:
AbstractEviction,ClockProPlusEviction,DelegatingEviction,IdleScanEviction,SegmentedEviction
public interface Eviction extends NeedsClose
Interface to the eviction data structure.- Author:
- Jens Wilke
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidchangeCapacity(long entryCountOrWeight)Change the capacity.voidcheckIntegrity(IntegrityState integrityState)voidevictEventually()Evict if needed, checks all segments.voidevictEventuallyBeforeInsert()Evict if needed, checks all segments.voidevictEventuallyBeforeInsertOnSegment(int hashCodeHint)Evict if needed, focused on the segment addressed by the hash code.longevictIdleEntries(int maxScan)Scan for idle (no access count since last scan) entries and evict them.EvictionMetricsgetMetrics()Get metrics related to the eviction.booleanisWeigherPresent()longremoveAll()Remove all entries from the eviction data structure.<T> TrunLocked(Supplier<T> j)Runs job making sure concurrent evictions operations pause.longstartNewIdleScanRound()Start new idle scan round and return current scan counterbooleansubmitWithoutTriggeringEviction(Entry e)Submit to eviction for inserting or removing from the replacement list.booleanupdateWeight(Entry e)Updates the weight on the entry and recalculates the total weight if needed.-
Methods inherited from interface org.cache2k.core.api.NeedsClose
close
-
-
-
-
Method Detail
-
startNewIdleScanRound
long startNewIdleScanRound()
Start new idle scan round and return current scan counter- See Also:
IdleScan
-
submitWithoutTriggeringEviction
boolean submitWithoutTriggeringEviction(Entry e)
Submit to eviction for inserting or removing from the replacement list. However, eviction should not be triggered (which in turn triggers a hash table update) since the hash segment lock is hold at the moment.
-
updateWeight
boolean updateWeight(Entry e)
Updates the weight on the entry and recalculates the total weight if needed.Expected not to hold the entry lock, which means, that this does not run in sync with the actual update. That is okay as long as it runs after every update.
Since we need to lock the eviction structure, this can happen in a separate thread.
- Returns:
- hint whether eviction should be run. for a bulk operation we want to do eviction once, so not do it within this method
-
evictEventuallyBeforeInsertOnSegment
void evictEventuallyBeforeInsertOnSegment(int hashCodeHint)
Evict if needed, focused on the segment addressed by the hash code. Called before a new entry is inserted (changed from after in v1.4)
-
evictEventuallyBeforeInsert
void evictEventuallyBeforeInsert()
Evict if needed, checks all segments. Called before a new entry is inserted (changed from after in v1.4)
-
evictEventually
void evictEventually()
Evict if needed, checks all segments.
-
evictIdleEntries
long evictIdleEntries(int maxScan)
Scan for idle (no access count since last scan) entries and evict them.- Returns:
- number of evicted entries
- See Also:
IdleScan
-
removeAll
long removeAll()
Remove all entries from the eviction data structure.- Returns:
- entry count
-
runLocked
<T> T runLocked(Supplier<T> j)
Runs job making sure concurrent evictions operations pause.
-
checkIntegrity
void checkIntegrity(IntegrityState integrityState)
-
getMetrics
EvictionMetrics getMetrics()
Get metrics related to the eviction. No lock is needed before calling this method. Best efforts are made to extract consistent statistics and keep interruption short.
-
isWeigherPresent
boolean isWeigherPresent()
-
changeCapacity
void changeCapacity(long entryCountOrWeight)
Change the capacity. If capacity is reduced, it will evict entries before returning.
-
-