Package wt.pom

Class RefreshCache

java.lang.Object
wt.pom.RefreshCache

public class RefreshCache extends Object
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
  • 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

      public boolean containskey(ObjectIdentifier key)
      check if the specified key exists

      Supported API: true
      Parameters:
      key - the entry key
      Returns:
      boolean indicate if the specified key exists
    • get

      public Object get(ObjectIdentifier key)
      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

      public void put(ObjectIdentifier key, Persistable value)
      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 key
      value - the value to associate with the given key
    • remove

      public void remove(ObjectIdentifier key)
      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

      public Enumeration entries()
      Returns an Enumeration of the entries in the cache.

      Supported API: true
    • toString

      public String 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
      Overrides:
      toString in class Object