Class CacheReplacementPolicyLRU<IdType,ObjectType,EntryType extends CacheEntry<ObjectType>>
java.lang.Object
se.liu.ida.hefquin.base.datastructures.impl.cache.CacheReplacementPolicyLRU<IdType,ObjectType,EntryType>
- All Implemented Interfaces:
CacheReplacementPolicy<IdType,ObjectType, EntryType>
public class CacheReplacementPolicyLRU<IdType,ObjectType,EntryType extends CacheEntry<ObjectType>>
extends Object
implements CacheReplacementPolicy<IdType,ObjectType,EntryType>
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CacheReplacementPolicyLRU<IdType,ObjectType, EntryType>.IdNode protected final Map<IdType,CacheReplacementPolicyLRU<IdType, ObjectType, EntryType>.IdNode> protected CacheReplacementPolicyLRU<IdType,ObjectType, EntryType>.IdNode -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Used by the cache to inform the replacement policy that the cache has been cleared.voidentryWasAdded(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).voidUsed by the cache to inform the replacement policy that the given entry has been evicted from the cache.voidentryWasRequested(IdType id, EntryType e) Used by the cache to inform the replacement policy that the given entry has been requested from the cache.voidentryWasRewritten(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.protected voidAttention, this method does not remove n fromnodes.
-
Field Details
-
nodes
protected final Map<IdType,CacheReplacementPolicyLRU<IdType, nodesObjectType, EntryType extends CacheEntry<ObjectType>>.IdNode> -
head
protected CacheReplacementPolicyLRU<IdType,ObjectType, headEntryType extends CacheEntry<ObjectType>>.IdNode -
tail
protected CacheReplacementPolicyLRU<IdType,ObjectType, tailEntryType extends CacheEntry<ObjectType>>.IdNode
-
-
Constructor Details
-
CacheReplacementPolicyLRU
public CacheReplacementPolicyLRU()
-
-
Method Details
-
getEvictionCandidates
Description copied from interface:CacheReplacementPolicyTries 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 callingCacheReplacementPolicy.entryWasEvicted(Object). This method may not return as many candidates as requests, (e.g., if there are not enough entries).- Specified by:
getEvictionCandidatesin interfaceCacheReplacementPolicy<IdType,ObjectType, EntryType extends CacheEntry<ObjectType>>
-
entryWasAdded
Description copied from interface:CacheReplacementPolicyUsed 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).- Specified by:
entryWasAddedin interfaceCacheReplacementPolicy<IdType,ObjectType, EntryType extends CacheEntry<ObjectType>>
-
entryWasRewritten
Description copied from interface:CacheReplacementPolicyUsed 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.- Specified by:
entryWasRewrittenin interfaceCacheReplacementPolicy<IdType,ObjectType, EntryType extends CacheEntry<ObjectType>>
-
entryWasRequested
Description copied from interface:CacheReplacementPolicyUsed by the cache to inform the replacement policy that the given entry has been requested from the cache.- Specified by:
entryWasRequestedin interfaceCacheReplacementPolicy<IdType,ObjectType, EntryType extends CacheEntry<ObjectType>>
-
entryWasEvicted
Description copied from interface:CacheReplacementPolicyUsed by the cache to inform the replacement policy that the given entry has been evicted from the cache.- Specified by:
entryWasEvictedin interfaceCacheReplacementPolicy<IdType,ObjectType, EntryType extends CacheEntry<ObjectType>>
-
clear
public void clear()Description copied from interface:CacheReplacementPolicyUsed by the cache to inform the replacement policy that the cache has been cleared.- Specified by:
clearin interfaceCacheReplacementPolicy<IdType,ObjectType, EntryType extends CacheEntry<ObjectType>>
-
removeFromList
Attention, this method does not remove n fromnodes.
-