Package org.jboss.util
Class LRUCachePolicy.LRUList
- java.lang.Object
-
- org.jboss.util.LRUCachePolicy.LRUList
-
- Enclosing class:
- LRUCachePolicy
public class LRUCachePolicy.LRUList extends java.lang.ObjectDouble queued list used to store cache entries.
-
-
Field Summary
Fields Modifier and Type Field Description intm_cacheMissThe cache misses happenedintm_capacityThe current capacity of the cache listintm_countThe number of cached objectsLRUCachePolicy.LRUCacheEntrym_headThe head of the double linked listintm_maxCapacityThe maximum capacity of the cache listintm_minCapacityThe minimum capacity of the cache listLRUCachePolicy.LRUCacheEntrym_tailThe tail of the double linked list
-
Constructor Summary
Constructors Modifier Constructor Description protectedLRUList()Creates a new double queued list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcapacityChanged(int oldCapacity)Callback that signals that the capacity of the cache is changed.protected voidclear()protected voiddemote()Demotes from the cache the least used entry.protected voidentryAdded(LRUCachePolicy.LRUCacheEntry entry)Callback that signals that the given entry has been added to the cache.protected voidentryPromotion(LRUCachePolicy.LRUCacheEntry entry)Callback that signals that the given entry is just about to be added.protected voidentryRemoved(LRUCachePolicy.LRUCacheEntry entry)Callback that signals that the given entry has been removed from the cache.protected voidpromote(LRUCachePolicy.LRUCacheEntry entry)Promotes the cache entryentryto the last used position of the list.protected voidremove(LRUCachePolicy.LRUCacheEntry entry)Removes from the cache list the specified entry.java.lang.StringtoString()
-
-
-
Field Detail
-
m_maxCapacity
public int m_maxCapacity
The maximum capacity of the cache list
-
m_minCapacity
public int m_minCapacity
The minimum capacity of the cache list
-
m_capacity
public int m_capacity
The current capacity of the cache list
-
m_count
public int m_count
The number of cached objects
-
m_head
public LRUCachePolicy.LRUCacheEntry m_head
The head of the double linked list
-
m_tail
public LRUCachePolicy.LRUCacheEntry m_tail
The tail of the double linked list
-
m_cacheMiss
public int m_cacheMiss
The cache misses happened
-
-
Method Detail
-
promote
protected void promote(LRUCachePolicy.LRUCacheEntry entry)
Promotes the cache entryentryto the last used position of the list.
If the object is already there, does nothing.- Parameters:
entry- the object to be promoted, cannot be null- Throws:
java.lang.IllegalStateException- if this method is called with a full cache- See Also:
demote()
-
demote
protected void demote()
Demotes from the cache the least used entry.
If the cache is not full, does nothing.
-
remove
protected void remove(LRUCachePolicy.LRUCacheEntry entry)
Removes from the cache list the specified entry.- Parameters:
entry-
-
entryPromotion
protected void entryPromotion(LRUCachePolicy.LRUCacheEntry entry)
Callback that signals that the given entry is just about to be added.- Parameters:
entry-
-
entryAdded
protected void entryAdded(LRUCachePolicy.LRUCacheEntry entry)
Callback that signals that the given entry has been added to the cache.- Parameters:
entry-
-
entryRemoved
protected void entryRemoved(LRUCachePolicy.LRUCacheEntry entry)
Callback that signals that the given entry has been removed from the cache.- Parameters:
entry-
-
capacityChanged
protected void capacityChanged(int oldCapacity)
Callback that signals that the capacity of the cache is changed.- Parameters:
oldCapacity- the capacity before the change happened
-
clear
protected void clear()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-