Package wt.pom
Class RefreshCache
java.lang.Object
wt.pom.RefreshCache
A fixed size, most recently used object cache.
The caches size is set at construction, and only the most recently used
entries are maintained. Each get or put operation makes that entry the
most recently used. When putting new entries, if the cache is full, the
least recently used entry is aged out of the cache.
Supported API: true
Extendable: false
Supported API: true
Extendable: false
-
Constructor Summary
ConstructorsConstructorDescriptionRefreshCache(int size) Construct a new fixed-size, most-recently-used cache. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the cache.booleancheck if the specified key exists
Supported API: trueentries()Returns anEnumerationof the entries in the cache.get(ObjectIdentifier key) Get an entry from the cache.voidput(ObjectIdentifier key, Persistable value) Put an entry in the cache.voidremove(ObjectIdentifier key) Remove an entry from the cache.toString()Returns string representation of the cache.
-
Constructor Details
-
RefreshCache
public RefreshCache(int size) Construct a new fixed-size, most-recently-used cache. Sparse arrays of shorts are used to maintain linked lists in a memory efficient manner - the maximum size supported by this implementation is 10922.
Supported API: true- Parameters:
size- the maximum number of entries stored in the cache.
-
-
Method Details
-
containskey
check if the specified key exists
Supported API: true- Parameters:
key- the entry key- Returns:
- boolean indicate if the specified key exists
-
get
Get an entry from the cache. Hit and miss statistics are updated.
Supported API: true- Parameters:
key- the entry key- Returns:
- the cached object or null if not found
-
put
Put an entry in the cache. If an entry for the given key already exists, the previous value is discarded. This entry is considered the most recently used.
Supported API: true- Parameters:
key- the entry keyvalue- the value to associate with the given key
-
remove
Remove an entry from the cache. Does nothing if the entry is not currently in the cache.
Supported API: true- Parameters:
key- the entry key
-
clear
public void clear()Clears the cache. All entries are removed.
Supported API: true -
entries
Returns anEnumerationof the entries in the cache.
Supported API: true -
toString
Returns string representation of the cache. The string contains the default string representation of the object plus a summary of the current cache size, hits and misses counts, and aged out entry count.
Supported API: true
-