Interface CacheReplacementPolicy<IdType,ObjectType,EntryType extends CacheEntry<ObjectType>>
- All Known Implementing Classes:
CacheReplacementPolicyLRU
public interface CacheReplacementPolicy<IdType,ObjectType,EntryType extends CacheEntry<ObjectType>>
Interface for classes that implement a replacement policy for a cache.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Used by the cache to inform the replacement policy that the cache has been cleared.void
entryWasAdded
(IdType id, EntryType e) Used by the cache to inform the replacement policy that the given entry has been added to the cache (which includes that the given ID is new).void
Used by the cache to inform the replacement policy that the given entry has been evicted from the cache.void
entryWasRequested
(IdType id, EntryType e) Used by the cache to inform the replacement policy that the given entry has been requested from the cache.void
entryWasRewritten
(IdType id, EntryType e) Used by the cache to inform the replacement policy that the given entry has been added to the cache as a new entry for the given ID.getEvictionCandidates
(int numberOfCandidates) Tries to determine the given number of cache entries as next candidates to be evicted from the cache.
-
Method Details
-
getEvictionCandidates
Tries to determine the given number of cache entries as next candidates to be evicted from the cache. The candidates are identified by the corresponding ID with which these entries are associated in the cache. While the identified entries are considered as candidates, they are not yet considered to be evicted (once they are, the cache will inform the replacement policy by callingentryWasEvicted(Object)
. This method may not return as many candidates as requests, (e.g., if there are not enough entries). -
entryWasAdded
-
entryWasRewritten
-
entryWasRequested
-
entryWasEvicted
Used by the cache to inform the replacement policy that the given entry has been evicted from the cache. -
clear
void clear()Used by the cache to inform the replacement policy that the cache has been cleared.
-