ColdBox Platform v3.8.0

coldbox.system.cache.providers
Class CacheBoxProvider

WEB-INF.cftags.component
        extended by coldbox.system.cache.AbstractCacheBoxProvider
            extended by coldbox.system.cache.providers.CacheBoxProvider
All Implemented Interfaces:
ICacheProvider
Direct Known Subclasses:
CacheBoxColdBoxProvider

public class CacheBoxProvider
extends AbstractCacheBoxProvider

The coolest standalone CacheBox Provider ever built

Constructor Summary
init()
          Constructor
 
Method Summary
 void _reap()
          Reap the cache, clear out everything that is dead
private void announceExpiration(any objectKey)
          Announce an Expiration
 any<boolean> clear(any objectKey)
          Clears an object from the cache by using its cache key
 void clearAll()
          Clear all the cache elements from the cache
 void clearByKeySnippet(any keySnippet, [any<boolean> regex='false'], [any<boolean> async='false'])
          Clears keys using the passed in object key snippet
 any<boolean> clearKey(any objectKey)
          Deprecated, please use clear()
 any<struct> clearMulti(any keys, [any prefix=''])
          Clears objects from the cache by using its cache key
 any<boolean> clearQuiet(any objectKey)
          Clears an object from the cache by using its cache key
 void configure()
          Configures the cache for operation, sets the configuration object, sets and creates the eviction policy and clears the stats
 void expireAll()
          Expire All Objects
 void expireByKeySnippet(any keySnippet, [any<boolean> regex='false'])
          Same as expireKey but can touch multiple objects depending on the keysnippet that is sent in
 void expireObject(any objectKey)
          Expire an Object
 any get(any objectKey)
          Get an object from cache
 any<struct> getCachedObjectMetadata(any objectKey)
          Get the cached object's metadata structure
 any<struct> getCachedObjectMetadataMulti(any keys, [any prefix=''])
          Get the cached object's metadata structure
 any getJavaRuntime()
          Get the java runtime object for reporting purposes
 any<array> getKeys()
          Get a listing of all the keys of the objects in the cache
 any<struct> getMulti(any keys, [any prefix=''])
          The returned value is a structure of name-value pairs of all the keys that where found
 any<IObjectStore> getObjectStore()
          If the cache provider implements it, this returns the cache's object store as type: coldbox
 any getOrSet(any objectKey, any produce, [any timeout=''], [any lastAccessTimeout=''], [any<struct> extra='[runtime expression]'])
          Tries to get an object from the cache, if not found, it calls the 'produce' closure to produce the data and cache it
 any getQuiet(any objectKey)
          Get an object from cache
 any<numeric> getSize()
          Get the cache's size in items
 any<struct> getStoreMetadataKeyMap()
          Get a key lookup structure where cachebox can build the report on
 any<struct> getStoreMetadataReport()
          Get a structure of all the keys in the cache with their appropriate metadata structures
 any<boolean> isExpired(any objectKey)
          Has the object key expired in the cache
private any locateEvictionPolicy([string policy])
          Locate the eviction policy
private any locateObjectStore([string store])
          Locate the object store
 any<boolean> lookup(any objectKey)
          Check if an object is in cache, if not found it records a miss
 any<struct> lookupMulti(any keys, [any prefix=''])
          The returned value is a structure of name-value pairs of all the keys that where found or not
 any<boolean> lookupQuiet(any objectKey)
          Check if an object is in cache quietly, advising nobody!
 void reap()
          Reap the cache, clear out everything that is dead
 any<boolean> set(any objectKey, any object, [any timeout=''], [any lastAccessTimeout=''], [any<struct> extra])
          sets an object in cache
 void setMulti(any<struct> mapping, [any timeout=''], [any lastAccessTimeout=''], [any prefix=''])
          Sets Multiple Ojects in the cache
 any<boolean> setQuiet(any objectKey, any object, [any timeout=''], [any lastAccessTimeout=''], [any<struct> extra])
          sets an object in cache
 void shutdown()
          Shutdown command issued when CacheBox is going through shutdown phase
private boolean thresholdChecks(any threshold='')
          JVM Threshold checks
private void validateConfiguration()
          Validate incoming set configuration data
 
Methods inherited from class coldbox.system.cache.AbstractCacheBoxProvider
clearStatistics, getCacheFactory, getCacheID, getConfiguration, getEventManager, getMemento, getName, getStats, getUtil, isEnabled, isReportingEnabled, setCacheFactory, setConfiguration, setEventManager, setName, statusCheck
 
Methods inherited from class WEB-INF.cftags.component
None
 

Constructor Detail

init

public init()
Constructor

Method Detail

_reap

public void _reap()
Reap the cache, clear out everything that is dead.


announceExpiration

private void announceExpiration(any objectKey)
Announce an Expiration

Parameters:
objectKey - The object cache key

clear

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

Specified by:
clear in interface ICacheProvider
Parameters:
objectKey - The object cache key

clearAll

public void clearAll()
Clear all the cache elements from the cache

Specified by:
clearAll in interface ICacheProvider

clearByKeySnippet

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

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

clearKey

public any<boolean> clearKey(any objectKey)
Deprecated, please use clear()

Parameters:
objectKey - The object cache key

clearMulti

public any<struct> clearMulti(any keys, [any 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 or array of keys to remove.
prefix - A prefix to prepend to the keys

clearQuiet

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

Specified by:
clearQuiet in interface ICacheProvider
Parameters:
objectKey - The object cache key

configure

public void configure()
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.

Specified by:
configure in interface ICacheProvider

expireAll

public void expireAll()
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

Specified by:
expireAll in interface ICacheProvider

expireByKeySnippet

public void expireByKeySnippet(any keySnippet, [any<boolean> regex='false'])
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

expireObject

public void expireObject(any objectKey)
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

Specified by:
expireObject in interface ICacheProvider
Parameters:
objectKey - The object cache key

get

public any get(any objectKey)
Get an object from cache. If object does not exist it returns null

Specified by:
get in interface ICacheProvider
Parameters:
objectKey - The key of the object to lookup.

getCachedObjectMetadata

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

Specified by:
getCachedObjectMetadata in interface ICacheProvider
Parameters:
objectKey - The key of the object to lookup its metadata

getCachedObjectMetadataMulti

public any<struct> getCachedObjectMetadataMulti(any keys, [any 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 or array of keys to retrieve from the cache.
prefix - A prefix to prepend to the keys

getJavaRuntime

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


getKeys

public any<array> getKeys()
Get a listing of all the keys of the objects in the cache

Specified by:
getKeys in interface ICacheProvider

getMulti

public any<struct> getMulti(any keys, [any 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 or array of keys to retrieve from the cache.
prefix - A prefix to prepend to the keys

getObjectStore

public any<IObjectStore> getObjectStore()
If the cache provider implements it, this returns the cache's object store as type: coldbox.system.cache.store.IObjectStore

Specified by:
getObjectStore in interface ICacheProvider

getOrSet

public any getOrSet(any objectKey, any produce, [any timeout=''], [any lastAccessTimeout=''], [any<struct> extra='[runtime expression]'])
Tries to get an object from the cache, if not found, it calls the 'produce' closure to produce the data and cache it.

Parameters:
objectKey - The object cache key
produce - The closure/udf to produce the data if not found
timeout - The timeout to use on the object (if any, provider specific)
lastAccessTimeout - The idle timeout to use on the object (if any, provider specific)
extra - A map of name-value pairs to use as extra arguments to pass to a providers set operation

getQuiet

public any getQuiet(any objectKey)
Get an object from cache. If object does not exist it returns null

Specified by:
getQuiet in interface ICacheProvider
Parameters:
objectKey - The key of the object to lookup.

getSize

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

Specified by:
getSize in interface ICacheProvider

getStoreMetadataKeyMap

public any<struct> getStoreMetadataKeyMap()
Get a key lookup structure where cachebox can build the report on. Ex: [timeout=timeout,lastAccessTimeout=idleTimeout]. It is a way for the visualizer to construct the columns correctly on the reports

Specified by:
getStoreMetadataKeyMap in interface ICacheProvider

getStoreMetadataReport

public any<struct> getStoreMetadataReport()
Get a structure of all the keys in the cache with their appropriate metadata structures. This is used to build the reporting.[keyX->[metadataStructure]]

Specified by:
getStoreMetadataReport in interface ICacheProvider

isExpired

public any<boolean> isExpired(any objectKey)
Has the object key expired in the cache

Specified by:
isExpired in interface ICacheProvider
Parameters:
objectKey - The object key

locateEvictionPolicy

private any locateEvictionPolicy([string policy])
Locate the eviction policy

Parameters:
policy

locateObjectStore

private any locateObjectStore([string store])
Locate the object store

Parameters:
store

lookup

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

Specified by:
lookup in interface ICacheProvider
Parameters:
objectKey - The key of the object to lookup.

lookupMulti

public any<struct> lookupMulti(any keys, [any prefix=''])
The returned value is a structure of name-value pairs of all the keys that where found or not.

Parameters:
keys - The comma delimited list or an array of keys to lookup in the cache.
prefix - A prefix to prepend to the keys

lookupQuiet

public any<boolean> lookupQuiet(any objectKey)
Check if an object is in cache quietly, advising nobody!

Specified by:
lookupQuiet in interface ICacheProvider
Parameters:
objectKey - The key of the object to lookup.

reap

public void reap()
Reap the cache, clear out everything that is dead.

Specified by:
reap in interface ICacheProvider

set

public any<boolean> set(any objectKey, any object, [any timeout=''], [any lastAccessTimeout=''], [any<struct> extra])
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.

Specified by:
set in interface ICacheProvider
Parameters:
objectKey - The object cache key
object - The object to cache
timeout - The timeout to use on the object (if any, provider specific)
lastAccessTimeout - The idle timeout to use on the object (if any, provider specific)
extra - A map of name-value pairs to use as extra arguments to pass to a providers set operation

setMulti

public void setMulti(any<struct> mapping, [any timeout=''], [any lastAccessTimeout=''], [any 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 - The timeout to use on the object (if any, provider specific)
lastAccessTimeout - The idle timeout to use on the object (if any, provider specific)
prefix - A prefix to prepend to the keys

setQuiet

public any<boolean> setQuiet(any objectKey, any object, [any timeout=''], [any lastAccessTimeout=''], [any<struct> extra])
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.

Specified by:
setQuiet in interface ICacheProvider
Parameters:
objectKey - The object cache key
object - The object to cache
timeout - The timeout to use on the object (if any, provider specific)
lastAccessTimeout - The idle timeout to use on the object (if any, provider specific)
extra - A map of name-value pairs to use as extra arguments to pass to a providers set operation

shutdown

public void shutdown()
Shutdown command issued when CacheBox is going through shutdown phase

Specified by:
shutdown in interface ICacheProvider

thresholdChecks

private boolean thresholdChecks(any threshold='')
JVM Threshold checks

Parameters:
threshold - The threshold to check

validateConfiguration

private void validateConfiguration()
Validate incoming set configuration data


ColdBox Platform v3.8.0