Class Cache

java.lang.Object
com.ibm.wsspi.cache.Cache

public class Cache extends Object
This is the underlying cache mechanism that is used by the CacheMonitor. It contains the methods used to inspect and manage the current state of the cache.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This method clears everything from the cache, so that it is just like when it was instantiated.
    void
    This method clears everything from the disk cache.
    This method returns the dependency IDs for all cache entries in the memory cache.
    This method returns the cache IDs for all cache entries from memory cache.
    This method returns the cache IDs of the entries in the memory cache specified by the dependency ID.
    This method returns the cache IDs of the entries in the memory cache specified by the template.
    This method returns an instance of CacheStatisticsListener.
    long
    This method returns a value for the disk cache cleanup frequency, in minutes.
    int
    This method returns the default priority value as set in the Administrator console GUI/dynacache.xml file.
    boolean
    This method returns a boolean to indicate whether the disk cache is using buffers for dependency IDs and templates.
    long
    This method returns a value for the maximum number of dependency identifier buckets in the disk cache metadata in memory.
    long
    This method returns a value for the maximum number of cache identifiers that are stored for an individual dependency ID or template in the disk cache metadata in memory.
    long
    This method returns a value for the maximum number of template buckets in the disk cache metadata in memory.
    getDepIdsByRangeDisk(int index, int length)
    This method returns the dependency IDs found in the disk cache based on specified the index and the length.
    int
    This method returns the current number of dependency IDs in the disk cache.
    This method returns the cache IDs of the entries in the disk cache specified by the dependency ID.
    long
    This method returns the maximum size of an individual cache entry in megabytes (MB).
    int
    This method returns the eviction algorithm that the disk cache will use to evict entries once the high threshold is reached.
    int
    This method returns the high threshold is expressed in terms of the percentage of the disk cache size in GB or entries.
    int
    This method returns the low threshold is expressed in terms of the percentage of the disk cache size in GB or entries.
    int
    This method returns the performance level to tune the performance of the disk cache.
    long
    This method returns the maximum number of disk cache size in gigabytes (GB).
    float
    This method returns the current disk cache size in Megabytes (MB).
    long
    This method returns the maximum number of cache entries that are held in disk cache.
    getEntry(Object cacheId)
    This method returns an instance of CacheEntry specified cache ID.
    This method returns the cache entry specified by cache ID from the disk cache.
    boolean
    This method returns a boolean to indicate whether in-memory cached objects are saved to disk when the server stops.
    getIdsByRangeDisk(int index, int length)
    This method returns the cache IDs found in the disk cache based on specified the index and the length.
    int
    This method returns the current number of cache entries in the disk cache.
    int
    This method returns the maximum space on the JVM heap that can be occupied by the cache entries.
    int
    This method returns the maximum number of cache entries that are held in memory cache.
    float
    This method returns the current space on the JVM heap that is occupied by the cache entries.
    int
    This method returns the current number of cache entries for this cache instance.
    boolean
    This method determines the disk offloaded feature is enabled or not.
    getTemplatesByRangeDisk(int index, int length)
    This method returns the templates found in the disk cache based on specified the index and the length.
    int
    This method returns the current number of templates in the disk cache.
    This method returns the cache IDs of the entries in the disk cache specified by the template.
    void
    invalidateById(String id, boolean waitOnInvalidation)
    This method invalidates in all caches all entries dependent on the specified id.
    void
    invalidateByTemplate(String template, boolean waitOnInvalidation)
    This method invalidates in all caches all entries dependent on the specified template.
    void
    This method moves the specified entry to the end of the LRU queue.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Cache

      public Cache(Cache ci)
  • Method Details

    • refreshEntry

      public void refreshEntry(CacheEntry ce)
      This method moves the specified entry to the end of the LRU queue.
      Parameters:
      ce - The cache entry
    • getSwapToDisk

      public boolean getSwapToDisk()
      This method determines the disk offloaded feature is enabled or not.
      Returns:
      True if disk offload feature is enabled. False if disk offload is disabled.
    • getEntryDisk

      public CacheEntry getEntryDisk(Object cacheId)
      This method returns the cache entry specified by cache ID from the disk cache.
      Parameters:
      cacheId - the cache ID
      Returns:
      The cache entry. NULL if cache ID does not exist.
    • clearDisk

      public void clearDisk()
      This method clears everything from the disk cache.
    • getIdsByRangeDisk

      public Collection getIdsByRangeDisk(int index, int length)
      This method returns the cache IDs found in the disk cache based on specified the index and the length. If index = 1 or -1, the set might contain "DISKCACHE_MORE" to indicate there are more cache IDs in the disk cache. The caller need to remove DISKCACHE_MORE" from the set before it is being used.
      Parameters:
      index - If index = 0, it starts the beginning. If index = 1, it means "next". If Index = -1, it means "previous".
      length - The max number of cache IDs to be read. If length = -1, it reads all cache IDs until the end.
      Returns:
      The collecton of cache IDs.
    • getTemplatesByRangeDisk

      public Collection getTemplatesByRangeDisk(int index, int length)
      This method returns the templates found in the disk cache based on specified the index and the length. If index = 1 or -1, the set might contain "DISKCACHE_MORE" to indicate there are more templates in the disk cache. The caller need to remove DISKCACHE_MORE" from the set before it is being used.
      Parameters:
      index - If index = 0, it starts the beginning. If index = 1, it means "next". If Index = -1, it means "previous".
      length - The max number of templates to be read. If length = -1, it reads all templates until the end.
      Returns:
      The collecton of templates.
    • getCacheStatisticsListener

      public CacheStatisticsListener getCacheStatisticsListener()
      This method returns an instance of CacheStatisticsListener.
      Returns:
      The instance of CacheStatisticsListener
    • getEntry

      public CacheEntry getEntry(Object cacheId)
      This method returns an instance of CacheEntry specified cache ID.
      Parameters:
      cacheId - the cache ID
      Returns:
      The instance of CacheEntry
    • invalidateById

      public void invalidateById(String id, boolean waitOnInvalidation)
      This method invalidates in all caches all entries dependent on the specified id.
      Parameters:
      id - The cache id or data id.
      waitOnInvalidation - True indicates that this method should not return until the invalidations have taken effect on all caches. False indicates that the invalidations will be queued for later batch processing.
    • invalidateByTemplate

      public void invalidateByTemplate(String template, boolean waitOnInvalidation)
      This method invalidates in all caches all entries dependent on the specified template.
      Parameters:
      template - The template name.
      waitOnInvalidation - True indicates that this method should not return until the invalidations have taken effect on all caches. False indicates that the invalidations will be queued for later batch processing.
    • clear

      public void clear()
      This method clears everything from the cache, so that it is just like when it was instantiated.
    • getAllIds

      public Enumeration getAllIds()
      This method returns the cache IDs for all cache entries from memory cache.
      Returns:
      The Enumeration of cache ids.
    • getMaxNumberCacheEntries

      public int getMaxNumberCacheEntries()
      This method returns the maximum number of cache entries that are held in memory cache.
      Returns:
      The maximum of cache entries.
    • getNumberCacheEntries

      public int getNumberCacheEntries()
      This method returns the current number of cache entries for this cache instance.
      Returns:
      The current number of cache entries.
    • getMaxCacheSizeInMB

      public int getMaxCacheSizeInMB()
      This method returns the maximum space on the JVM heap that can be occupied by the cache entries.
      Returns:
      The maximum size of cache allowed in terms of JVM heap.
    • getMemoryCacheSizeInMB

      public float getMemoryCacheSizeInMB()
      This method returns the current space on the JVM heap that is occupied by the cache entries.
      Returns:
      The current size of cache in terms of JVM heap.
    • getDefaultPriority

      public int getDefaultPriority()
      This method returns the default priority value as set in the Administrator console GUI/dynacache.xml file.
      Returns:
      The default priority
    • getAllDependencyIds

      public Collection getAllDependencyIds()
      This method returns the dependency IDs for all cache entries in the memory cache.
      Returns:
      A Collection of dependency IDs.
    • getCacheIdsByDependency

      public Collection getCacheIdsByDependency(String dependency)
      This method returns the cache IDs of the entries in the memory cache specified by the dependency ID.
      Parameters:
      dependency - ID for the group of cache IDs.
      Returns:
      A Collection of cache IDs
    • getCacheIdsByTemplate

      public Collection getCacheIdsByTemplate(String template)
      This method returns the cache IDs of the entries in the memory cache specified by the template.
      Parameters:
      template - for the group of cache IDs.
      Returns:
      A Collection of cache IDs
    • getTemplatesSizeDisk

      public int getTemplatesSizeDisk()
      This method returns the current number of templates in the disk cache.
      Returns:
      The current number of templates
    • getTemplateValueDisk

      public Collection getTemplateValueDisk(String template)
      This method returns the cache IDs of the entries in the disk cache specified by the template.
      Parameters:
      template - for the group of cache IDs.
      Returns:
      A Collection of cache IDs
    • getIdsSizeDisk

      public int getIdsSizeDisk()
      This method returns the current number of cache entries in the disk cache.
      Returns:
      The current number of cache entries
    • getDepIdsSizeDisk

      public int getDepIdsSizeDisk()
      This method returns the current number of dependency IDs in the disk cache.
      Returns:
      The current number of dependency IDs
    • getDepIdsByRangeDisk

      public Collection getDepIdsByRangeDisk(int index, int length)
      This method returns the dependency IDs found in the disk cache based on specified the index and the length. If index = 1 or -1, the set might contain "DISKCACHE_MORE" to indicate there are more dependency IDs in the disk cache. The caller need to remove DISKCACHE_MORE" from the set before it is being used.
      Parameters:
      index - If index = 0, it starts the beginning. If index = 1, it means "next". If Index = -1, it means "previous".
      length - The max number of dependency IDs to be read. If length = -1, it reads all dependency IDs until the end.
      Returns:
      The collecton of dependency IDs.
    • getDepIdValueDisk

      public Collection getDepIdValueDisk(Object depId)
      This method returns the cache IDs of the entries in the disk cache specified by the dependency ID.
      Parameters:
      depId - for the group of cache IDs.
      Returns:
      A Collection of cache IDs
    • getDiskCacheSizeLimit

      public long getDiskCacheSizeLimit()
      This method returns the maximum number of cache entries that are held in disk cache.
      Returns:
      The maximum of disk cache entries.
    • getDiskCacheSizeInGBLimit

      public long getDiskCacheSizeInGBLimit()
      This method returns the maximum number of disk cache size in gigabytes (GB).
      Returns:
      The maximum of disk cache size in GB.
    • getDiskCacheEntrySizeInMBLimit

      public long getDiskCacheEntrySizeInMBLimit()
      This method returns the maximum size of an individual cache entry in megabytes (MB). Any cache entry that is larger than this, when evicted from memory, will not be offloaded to disk.
      Returns:
      The maximum of disk cache entry size in MB.
    • getFlushToDiskOnStop

      public boolean getFlushToDiskOnStop()
      This method returns a boolean to indicate whether in-memory cached objects are saved to disk when the server stops.
      Returns:
      boolean flushToDiskOnStop true or false
    • getDiskCachePerformanceLevel

      public int getDiskCachePerformanceLevel()
      This method returns the performance level to tune the performance of the disk cache.
      Returns:
      Peformance level 0=low 1=balance 2=custom 3=high
    • getCleanupFrequency

      public long getCleanupFrequency()
      This method returns a value for the disk cache cleanup frequency, in minutes. If this value is set to 0, the cleanup runs only at midnight. This setting applies only when the Disk Offload Performance Level is low, balanced, or custom. The high performance level does not require disk cleanup, and this value is ignored.
      Returns:
      Cleanup frequency in minutes
    • getDelayOffload

      public boolean getDelayOffload()
      This method returns a boolean to indicate whether the disk cache is using buffers for dependency IDs and templates.
      Returns:
      boolean delayOffload true or false
    • getDelayOffloadEntriesLimit

      public long getDelayOffloadEntriesLimit()
      This method returns a value for the maximum number of cache identifiers that are stored for an individual dependency ID or template in the disk cache metadata in memory. If this limit is exceeded, the information is offloaded to the disk. This setting applies only when the disk offload performance level is custom.
      Returns:
      Delay offload entries limit
    • getDelayOffloadDepIdBuckets

      public long getDelayOffloadDepIdBuckets()
      This method returns a value for the maximum number of dependency identifier buckets in the disk cache metadata in memory. If this limit is exceeded, the information is offloaded to the disk. This setting applies only when the disk cache performance level is custom.
      Returns:
      Delay offload dependency id buckets
    • getDelayOffloadTemplateBuckets

      public long getDelayOffloadTemplateBuckets()
      This method returns a value for the maximum number of template buckets in the disk cache metadata in memory. If this limit is exceeded, the information is offloaded to the disk. This setting applies only when the disk cache performance level is custom.
      Returns:
      Delay offload template buckets
    • getDiskCacheEvictionPolicy

      public int getDiskCacheEvictionPolicy()
      This method returns the eviction algorithm that the disk cache will use to evict entries once the high threshold is reached.
      Returns:
      Eviction policy 0=disable 1=random 2:size
    • getDiskCacheHighThreshold

      public int getDiskCacheHighThreshold()
      This method returns the high threshold is expressed in terms of the percentage of the disk cache size in GB or entries. The high value is used when limit disk cache size in GB and limit disk cache size in entries are specified.
      Returns:
      High threshold in percentage
    • getDiskCacheLowThreshold

      public int getDiskCacheLowThreshold()
      This method returns the low threshold is expressed in terms of the percentage of the disk cache size in GB or entries. The lower value is used when limit disk cache size in GB and limit disk cache size in entries are specified.
      Returns:
      Low threshold in percentage
    • getDiskCacheSizeInMBs

      public float getDiskCacheSizeInMBs()
      This method returns the current disk cache size in Megabytes (MB).
      Returns:
      current disk cache size in MB