Package com.ibm.wsspi.cache
Class Cache
- java.lang.Object
-
- com.ibm.wsspi.cache.Cache
-
public class Cache extends java.lang.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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
This method clears everything from the cache, so that it is just like when it was instantiated.void
clearDisk()
This method clears everything from the disk cache.java.util.Collection
getAllDependencyIds()
This method returns the dependency IDs for all cache entries in the memory cache.java.util.Enumeration
getAllIds()
This method returns the cache IDs for all cache entries from memory cache.java.util.Collection
getCacheIdsByDependency(java.lang.String dependency)
This method returns the cache IDs of the entries in the memory cache specified by the dependency ID.java.util.Collection
getCacheIdsByTemplate(java.lang.String template)
This method returns the cache IDs of the entries in the memory cache specified by the template.CacheStatisticsListener
getCacheStatisticsListener()
This method returns an instance of CacheStatisticsListener.long
getCleanupFrequency()
This method returns a value for the disk cache cleanup frequency, in minutes.int
getDefaultPriority()
This method returns the default priority value as set in the Administrator console GUI/dynacache.xml file.boolean
getDelayOffload()
This method returns a boolean to indicate whether the disk cache is using buffers for dependency IDs and templates.long
getDelayOffloadDepIdBuckets()
This method returns a value for the maximum number of dependency identifier buckets in the disk cache metadata in memory.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.long
getDelayOffloadTemplateBuckets()
This method returns a value for the maximum number of template buckets in the disk cache metadata in memory.java.util.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.int
getDepIdsSizeDisk()
This method returns the current number of dependency IDs in the disk cache.java.util.Collection
getDepIdValueDisk(java.lang.Object depId)
This method returns the cache IDs of the entries in the disk cache specified by the dependency ID.long
getDiskCacheEntrySizeInMBLimit()
This method returns the maximum size of an individual cache entry in megabytes (MB).int
getDiskCacheEvictionPolicy()
This method returns the eviction algorithm that the disk cache will use to evict entries once the high threshold is reached.int
getDiskCacheHighThreshold()
This method returns the high threshold is expressed in terms of the percentage of the disk cache size in GB or entries.int
getDiskCacheLowThreshold()
This method returns the low threshold is expressed in terms of the percentage of the disk cache size in GB or entries.int
getDiskCachePerformanceLevel()
This method returns the performance level to tune the performance of the disk cache.long
getDiskCacheSizeInGBLimit()
This method returns the maximum number of disk cache size in gigabytes (GB).float
getDiskCacheSizeInMBs()
This method returns the current disk cache size in Megabytes (MB).long
getDiskCacheSizeLimit()
This method returns the maximum number of cache entries that are held in disk cache.CacheEntry
getEntry(java.lang.Object cacheId)
This method returns an instance of CacheEntry specified cache ID.CacheEntry
getEntryDisk(java.lang.Object cacheId)
This method returns the cache entry specified by cache ID from the disk cache.boolean
getFlushToDiskOnStop()
This method returns a boolean to indicate whether in-memory cached objects are saved to disk when the server stops.java.util.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.int
getIdsSizeDisk()
This method returns the current number of cache entries in the disk cache.int
getMaxCacheSizeInMB()
This method returns the maximum space on the JVM heap that can be occupied by the cache entries.int
getMaxNumberCacheEntries()
This method returns the maximum number of cache entries that are held in memory cache.float
getMemoryCacheSizeInMB()
This method returns the current space on the JVM heap that is occupied by the cache entries.int
getNumberCacheEntries()
This method returns the current number of cache entries for this cache instance.boolean
getSwapToDisk()
This method determines the disk offloaded feature is enabled or not.java.util.Collection
getTemplatesByRangeDisk(int index, int length)
This method returns the templates found in the disk cache based on specified the index and the length.int
getTemplatesSizeDisk()
This method returns the current number of templates in the disk cache.java.util.Collection
getTemplateValueDisk(java.lang.String template)
This method returns the cache IDs of the entries in the disk cache specified by the template.void
invalidateById(java.lang.String id, boolean waitOnInvalidation)
This method invalidates in all caches all entries dependent on the specified id.void
invalidateByTemplate(java.lang.String template, boolean waitOnInvalidation)
This method invalidates in all caches all entries dependent on the specified template.void
refreshEntry(CacheEntry ce)
This method moves the specified entry to the end of the LRU queue.
-
-
-
Constructor Detail
-
Cache
public Cache(Cache ci)
-
-
Method Detail
-
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(java.lang.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 java.util.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 java.util.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(java.lang.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(java.lang.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(java.lang.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 java.util.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 java.util.Collection getAllDependencyIds()
This method returns the dependency IDs for all cache entries in the memory cache.- Returns:
- A Collection of dependency IDs.
-
getCacheIdsByDependency
public java.util.Collection getCacheIdsByDependency(java.lang.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 java.util.Collection getCacheIdsByTemplate(java.lang.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 java.util.Collection getTemplateValueDisk(java.lang.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 java.util.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 java.util.Collection getDepIdValueDisk(java.lang.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
-
-