ColdBox Platform Version 2.6.3

coldbox.system.cache
Class CacheManager

WEB-INF.cftags.component
        extended by coldbox.system.cache.CacheManager
Direct Known Subclasses:
MTCacheManager

public class CacheManager
extends WEB-INF.cftags.component

Manages handler,plugin,custom plugin and object caching. It is thread safe and implements locking for you.


Constructor Summary
init(any controller)
          Constructor
 
Method Summary
private boolean ThresholdChecks()
          JVM Threshold checks
private void announceExpiration(string objectKey)
          Announce an Expiration
 void clear()
          Clears the entire object cache and recreates the object pool and statistics. Call from a non-cached object or you will get 500 NULL errors, VERY VERY BAD!!. TRY NOT TO USE THIS METHOD
 void clearAllEvents([boolean async='true'])
          Clears all events from the cache.
 void clearAllViews([boolean async='true'])
          Clears all views from the cache.
 void clearByKeySnippet(string keySnippet, [boolean regex='false'], [boolean async='true'])
          Clears keys using the passed in object key snippet
 void clearEvent(string eventsnippet, [string queryString=''], [boolean async='true'])
          Clears all the event permutations from the cache according to snippet and querystring. Be careful when using incomplete event name with query strings as partial event names are not guaranteed to match with query string permutations
 boolean clearKey(string objectKey)
          Clears an object from the cache by using its cache key. Returns false if object was not removed or did not exist anymore
 struct clearKeyMulti(string keys, [string prefix=''])
          Clears objects from the cache by using its cache key. The returned value is a structure of name-value pairs of all the keys that where removed from the operation.
 void clearView(string viewSnippet, [boolean async='true'])
          Clears all view name permutations from the cache according to the view name.
 void configure(CacheConfigBean cacheConfigBean)
          Configures the cache for operation, sets the configuration object, sets and creates the eviction policy and clears the stats. If this method is not called, the cache is useless.
 void expireAll([boolean async='true'])
          Expire All Objects. Use this instead of clear() from within handlers or any cached object, this sets the metadata for the objects to expire in the next request. Note that this is not an inmmediate expiration. Clear should only be used from outside a cached object
 void expireByKeySnippet(string keySnippet, [boolean regex='false'], [boolean async='true'])
          Same as expireKey but can touch multiple objects depending on the keysnippet that is sent in.
 void expireKey(string objectKey, [boolean async='true'])
          Expire an Object. Use this instead of clearKey() from within handlers or any cached object, this sets the metadata for the objects to expire in the next request. Note that this is not an inmmediate expiration. Clear should only be used from outside a cached object
 any get(any objectKey)
          Get an object from cache. If it doesn't exist it returns the THIS.NOT_FOUND value
 CacheConfigBean getCacheConfigBean()
          Get the current cache configuration bean.
 CacheStats getCacheStats()
          Return the cache stats object.
 struct getCachedObjectMetadata(any objectKey)
          Get the cached object's metadata structure. If the object does not exist, it returns an empty structure.
 struct getCachedObjectMetadataMulti(string keys, [string prefix=''])
          Get the cached object's metadata structure. If the object does not exist, it returns an empty structure.
 struct getItemTypes()
          Get the item types of the cache. These are calculated according to internal coldbox entry prefixes
 struct getMulti(string keys, [string prefix=''])
          The returned value is a structure of name-value pairs of all the keys that where found. Not found values will not be returned
 any getObjectPool()
          Get the internal object pool: coldbox.system.cache.objectPool or MTobjectPool
 numeric getSize()
          Get the cache's size in items
private Util getUtil()
          Create and return a util object
 EventURLFacade geteventURLFacade()
          Get the event url facade object.
 any getjavaRuntime()
          Get the java runtime object for reporting purposes.
 struct getpool_metadata()
          Get the pool's metadata structure
private void initPool()
          Initialize and set the internal object Pool
 boolean lookup(any objectKey)
          Check if an object is in cache, if not found it records a miss.
 void reap()
          Reap the cache.
 boolean set(any objectKey, any MyObject, [any Timeout=''], [any LastAccessTimeout=''])
          sets an object in cache. Sets might be expensive. If the JVM threshold is used and it has been reached, the object won't be cached. If the pool is at maximum it will expire using its eviction policy and still cache the object. Cleanup will be done later.
 void setCacheConfigBean(CacheConfigBean CacheConfigBean)
          Set & Override the cache configuration bean. You can use this to programmatically alter the cache.
 void setMulti(struct mapping, [any Timeout=''], [any LastAccessTimeout=''], [string prefix=''])
          Sets Multiple Ojects in the cache. Sets might be expensive. If the JVM threshold is used and it has been reached, the object won't be cached. If the pool is at maximum it will expire using its eviction policy and still cache the object. Cleanup will be done later.
 void setevictionPolicy(AbstractEvictionPolicy evictionPolicy)
          You can now override the set eviction policy by programmatically sending it in.
 
Methods inherited from class WEB-INF.cftags.component
 

Constructor Detail

init

public init(any controller)

Method Detail

ThresholdChecks

private boolean ThresholdChecks()
JVM Threshold checks


announceExpiration

private void announceExpiration(string objectKey)
Announce an Expiration

Parameters:
objectKey - The object key to announce expiration

clear

public void clear()
Clears the entire object cache and recreates the object pool and statistics. Call from a non-cached object or you will get 500 NULL errors, VERY VERY BAD!!. TRY NOT TO USE THIS METHOD


clearAllEvents

public void clearAllEvents([boolean async='true'])
Clears all events from the cache.

Parameters:
async - Run asynchronously or not

clearAllViews

public void clearAllViews([boolean async='true'])
Clears all views from the cache.

Parameters:
async - Run asynchronously or not

clearByKeySnippet

public void clearByKeySnippet(string keySnippet, [boolean regex='false'], [boolean async='true'])
Clears keys using the passed in object key snippet

Parameters:
keySnippet - the cache key snippet to use
regex - Use regex or not
async - Run asynchronously or not

clearEvent

public void clearEvent(string eventsnippet, [string queryString=''], [boolean async='true'])
Clears all the event permutations from the cache according to snippet and querystring. Be careful when using incomplete event name with query strings as partial event names are not guaranteed to match with query string permutations

Parameters:
eventsnippet - The event snippet to clear on. Can be partial or full
queryString - If passed in, it will create a unique hash out of it. For purging purposes
async - Run asynchronously or not

clearKey

public boolean clearKey(string objectKey)
Clears an object from the cache by using its cache key. Returns false if object was not removed or did not exist anymore

Parameters:
objectKey - The key the object was stored under.

clearKeyMulti

public struct clearKeyMulti(string keys, [string prefix=''])
Clears objects from the cache by using its cache key. The returned value is a structure of name-value pairs of all the keys that where removed from the operation.

Parameters:
keys - The comma-delimmitted list of keys to remove.
prefix - A prefix to prepend to the keys

clearView

public void clearView(string viewSnippet, [boolean async='true'])
Clears all view name permutations from the cache according to the view name.

Parameters:
viewSnippet - The view name snippet to purge from the cache
async - Run asynchronously or not

configure

public void configure(CacheConfigBean cacheConfigBean)
Configures the cache for operation, sets the configuration object, sets and creates the eviction policy and clears the stats. If this method is not called, the cache is useless.

Parameters:
cacheConfigBean - The configuration object

expireAll

public void expireAll([boolean async='true'])
Expire All Objects. Use this instead of clear() from within handlers or any cached object, this sets the metadata for the objects to expire in the next request. Note that this is not an inmmediate expiration. Clear should only be used from outside a cached object

Parameters:
async - Run asynchronously or not

expireByKeySnippet

public void expireByKeySnippet(string keySnippet, [boolean regex='false'], [boolean async='true'])
Same as expireKey but can touch multiple objects depending on the keysnippet that is sent in.

Parameters:
keySnippet - The key snippet to use
regex - Use regex or not
async - Run asynchronously or not

expireKey

public void expireKey(string objectKey, [boolean async='true'])
Expire an Object. Use this instead of clearKey() from within handlers or any cached object, this sets the metadata for the objects to expire in the next request. Note that this is not an inmmediate expiration. Clear should only be used from outside a cached object

Parameters:
objectKey
async - Run asynchronously or not

get

public any get(any objectKey)
Get an object from cache. If it doesn't exist it returns the THIS.NOT_FOUND value

Parameters:
objectKey - The key of the object to lookup.

getCacheConfigBean

public CacheConfigBean getCacheConfigBean()
Get the current cache configuration bean.


getCacheStats

public CacheStats getCacheStats()
Return the cache stats object.


getCachedObjectMetadata

public struct getCachedObjectMetadata(any objectKey)
Get the cached object's metadata structure. If the object does not exist, it returns an empty structure.

Parameters:
objectKey - The key of the object to lookup its metadata

getCachedObjectMetadataMulti

public struct getCachedObjectMetadataMulti(string keys, [string prefix=''])
Get the cached object's metadata structure. If the object does not exist, it returns an empty structure.

Parameters:
keys - The comma delimited list of keys to retrieve from the cache.
prefix - A prefix to prepend to the keys

getItemTypes

public struct getItemTypes()
Get the item types of the cache. These are calculated according to internal coldbox entry prefixes


getMulti

public struct getMulti(string keys, [string prefix=''])
The returned value is a structure of name-value pairs of all the keys that where found. Not found values will not be returned

Parameters:
keys - The comma delimited list of keys to retrieve from the cache.
prefix - A prefix to prepend to the keys

getObjectPool

public any getObjectPool()
Get the internal object pool: coldbox.system.cache.objectPool or MTobjectPool


getSize

public numeric getSize()
Get the cache's size in items


getUtil

private Util getUtil()
Create and return a util object


geteventURLFacade

public EventURLFacade geteventURLFacade()
Get the event url facade object.


getjavaRuntime

public any getjavaRuntime()
Get the java runtime object for reporting purposes.


getpool_metadata

public struct getpool_metadata()
Get the pool's metadata structure


initPool

private void initPool()
Initialize and set the internal object Pool


lookup

public boolean lookup(any objectKey)
Check if an object is in cache, if not found it records a miss.

Parameters:
objectKey - The key of the object to lookup.

reap

public void reap()
Reap the cache.


set

public boolean set(any objectKey, any MyObject, [any Timeout=''], [any LastAccessTimeout=''])
sets an object in cache. Sets might be expensive. If the JVM threshold is used and it has been reached, the object won't be cached. If the pool is at maximum it will expire using its eviction policy and still cache the object. Cleanup will be done later.

Parameters:
objectKey - The object cache key
MyObject - The object to cache
Timeout - Timeout in minutes. If timeout = 0 then object never times out. If timeout is blank, then timeout will be inherited from framework.
LastAccessTimeout - Last Access Timeout in minutes. If timeout is blank, then timeout will be inherited from framework.

setCacheConfigBean

public void setCacheConfigBean(CacheConfigBean CacheConfigBean)
Set & Override the cache configuration bean. You can use this to programmatically alter the cache.

Parameters:
CacheConfigBean

setMulti

public void setMulti(struct mapping, [any Timeout=''], [any LastAccessTimeout=''], [string prefix=''])
Sets Multiple Ojects in the cache. Sets might be expensive. If the JVM threshold is used and it has been reached, the object won't be cached. If the pool is at maximum it will expire using its eviction policy and still cache the object. Cleanup will be done later.

Parameters:
mapping - The structure of name value pairs to cache
Timeout - Timeout in minutes. If timeout = 0 then object never times out. If timeout is blank, then timeout will be inherited from framework.
LastAccessTimeout - Last Access Timeout in minutes. If timeout is blank, then timeout will be inherited from framework.
prefix - A prefix to prepend to the keys

setevictionPolicy

public void setevictionPolicy(AbstractEvictionPolicy evictionPolicy)
You can now override the set eviction policy by programmatically sending it in.

Parameters:
evictionPolicy

ColdBox Platform Version 2.6.3