Class BufferCache<K>
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.util.LRUCache<K,IBuffer>
org.aspectj.org.eclipse.jdt.internal.core.OverflowingLRUCache<K,IBuffer>
org.aspectj.org.eclipse.jdt.internal.core.BufferCache<K>
- All Implemented Interfaces:
Cloneable
An LRU cache of
IBuffers.-
Nested Class Summary
Nested classes/interfaces inherited from class LRUCache
LRUCache.LRUCacheEntry<K,V>, LRUCache.Stats Modifier and TypeClassDescriptionstatic classThis type is used internally by the LRUCache to represent entries stored in the cache.class -
Field Summary
Fields inherited from class OverflowingLRUCache
loadFactor, overflow, timestampsOnModifier and TypeFieldDescriptionprotected doubleIndicates how much space should be reclaimed when the cache overflows.protected intIndicates if the cache has been over filled and by how much.protected booleanIndicates whether or not timestamps should be updatedFields inherited from class LRUCache
currentSpace, DEFAULT_SPACELIMIT, entryQueue, entryQueueTail, entryTable, spaceLimit, timestampCounterModifier and TypeFieldDescriptionprotected intAmount of cache space used so farprotected static final intDefault amount of space in the cacheprotected LRUCache.LRUCacheEntry<K, IBuffer> Start of queue (most recently used entry)protected LRUCache.LRUCacheEntry<K, IBuffer> End of queue (least recently used entry)protected Hashtable<K, LRUCache.LRUCacheEntry<K, IBuffer>> Hash table for fast random access to cache entriesprotected intMaximum space allowed in cacheprotected intCounter for handing out sequential timestamps -
Constructor Summary
ConstructorsConstructorDescriptionBufferCache(int size) Constructs a new buffer cache of the given size.BufferCache(int size, int overflow) Constructs a new buffer cache of the given size. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanclose(LRUCache.LRUCacheEntry<K, IBuffer> entry) Returns true if the element is successfully closed and removed from the cache, otherwise false.newInstance(int size, int newOverflow) Returns a new instance of the reciever.Methods inherited from class OverflowingLRUCache
clone, elements, fillingRatio, getEntryTable, getLoadFactor, getOverflow, makeSpace, printStats, privateRemoveEntry, privateRemoveEntry, put, remove, setLoadFactor, setSpaceLimit, shrink, toString, updateTimestampModifier and TypeMethodDescriptionclone()Returns a new cache containing the same contents.elements()Returns an enumerator of the values in the cache with the most recently used first.doubleFor internal testing only.doubleReturns the load factor for the cache.intprotected booleanmakeSpace(int space) Ensures there is the specified amount of free space in the receiver, by removing old entries if necessary.voidFor testing purposes onlyprotected voidprivateRemoveEntry(LRUCache.LRUCacheEntry<K, IBuffer> entry, boolean shuffle) Removes the entry from the entry queue.protected voidprivateRemoveEntry(LRUCache.LRUCacheEntry<K, IBuffer> entry, boolean shuffle, boolean external) Removes the entry from the entry queue.Sets the value in the cache at the given key.Removes and returns the value in the cache for the given key.voidsetLoadFactor(double newLoadFactor) Sets the load factor for the cache.voidsetSpaceLimit(int limit) Sets the maximum amount of space that the cache can storebooleanshrink()Attempts to shrink the cache if it has overflown.toString()Returns a String that represents the value of this object.protected voidUpdates the timestamp for the given entry, ensuring that the queue is kept in correct order.Methods inherited from class LRUCache
flush, flush, get, getCurrentSpace, getKey, getNewestTimestampCounter, getOldestElement, getOldestTimestampCounter, getSpaceLimit, keys, keysAndValues, newInstance, peek, privateAdd, privateAddEntry, removeKey, spaceFor, toStringContents, toStringFillingRationModifier and TypeMethodDescriptionvoidflush()Flushes all entries from the cache.voidFlushes the given entry from the cache.Answers the value in the cache at the given key.intReturns the amount of space that is current used in the cache.intReturns the timestamps of the most recently used element in the cache.Returns the lest recently used element in the cache, can returnnullintReturns the timestamps of the least recently used element in the cache.intReturns the maximum amount of space available in the cache.keys()Returns an Enumeration of the keys currently in the cache.Returns an enumeration that iterates over all the keys and values currently in the cache.newInstance(int size) Returns a new LRUCache instanceAnswers the value in the cache at the given key.protected voidprivateAdd(K key, IBuffer value, int space) Adds an entry for the given key/value/space.protected voidprivateAddEntry(LRUCache.LRUCacheEntry<K, IBuffer> entry, boolean shuffle) Adds the given entry from the receiver.Removes and returns the value in the cache for the given key.protected intReturns the space taken by the given value.protected StringReturns a String that represents the contents of this object.toStringFillingRation(String cacheName)
-
Constructor Details
-
BufferCache
public BufferCache(int size) Constructs a new buffer cache of the given size. -
BufferCache
public BufferCache(int size, int overflow) Constructs a new buffer cache of the given size.
-
-
Method Details
-
close
Description copied from class:OverflowingLRUCacheReturns true if the element is successfully closed and removed from the cache, otherwise false.NOTE: this triggers an external remove from the cache by closing the object.
- Specified by:
closein classOverflowingLRUCache<K,IBuffer>
-
newInstance
Description copied from class:OverflowingLRUCacheReturns a new instance of the reciever.- Specified by:
newInstancein classOverflowingLRUCache<K,IBuffer>
-