|
ColdBox Platform Version 2.6.3 | ||||
FRAMES |
WEB-INF.cftags.componentcoldbox.system.cache.CacheManager
public class CacheManager
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 |
---|
public init(any controller)
Method Detail |
---|
private boolean ThresholdChecks()
private void announceExpiration(string objectKey)
objectKey
- The object key to announce expirationpublic void clear()
public void clearAllEvents([boolean async='true'])
async
- Run asynchronously or notpublic void clearAllViews([boolean async='true'])
async
- Run asynchronously or notpublic void clearByKeySnippet(string keySnippet, [boolean regex='false'], [boolean async='true'])
keySnippet
- the cache key snippet to useregex
- Use regex or notasync
- Run asynchronously or notpublic void clearEvent(string eventsnippet, [string queryString=''], [boolean async='true'])
eventsnippet
- The event snippet to clear on. Can be partial or fullqueryString
- If passed in, it will create a unique hash out of it. For purging purposesasync
- Run asynchronously or notpublic boolean clearKey(string objectKey)
objectKey
- The key the object was stored under.public struct clearKeyMulti(string keys, [string prefix=''])
keys
- The comma-delimmitted list of keys to remove.prefix
- A prefix to prepend to the keyspublic void clearView(string viewSnippet, [boolean async='true'])
viewSnippet
- The view name snippet to purge from the cacheasync
- Run asynchronously or notpublic void configure(CacheConfigBean cacheConfigBean)
cacheConfigBean
- The configuration objectpublic void expireAll([boolean async='true'])
async
- Run asynchronously or notpublic void expireByKeySnippet(string keySnippet, [boolean regex='false'], [boolean async='true'])
keySnippet
- The key snippet to useregex
- Use regex or notasync
- Run asynchronously or notpublic void expireKey(string objectKey, [boolean async='true'])
objectKey
async
- Run asynchronously or notpublic any get(any objectKey)
objectKey
- The key of the object to lookup.public CacheConfigBean getCacheConfigBean()
public CacheStats getCacheStats()
public struct getCachedObjectMetadata(any objectKey)
objectKey
- The key of the object to lookup its metadatapublic struct getCachedObjectMetadataMulti(string keys, [string prefix=''])
keys
- The comma delimited list of keys to retrieve from the cache.prefix
- A prefix to prepend to the keyspublic struct getItemTypes()
public struct getMulti(string keys, [string prefix=''])
keys
- The comma delimited list of keys to retrieve from the cache.prefix
- A prefix to prepend to the keyspublic any getObjectPool()
public numeric getSize()
private Util getUtil()
public EventURLFacade geteventURLFacade()
public any getjavaRuntime()
public struct getpool_metadata()
private void initPool()
public boolean lookup(any objectKey)
objectKey
- The key of the object to lookup.public void reap()
public boolean set(any objectKey, any MyObject, [any Timeout=''], [any LastAccessTimeout=''])
objectKey
- The object cache keyMyObject
- The object to cacheTimeout
- 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.public void setCacheConfigBean(CacheConfigBean CacheConfigBean)
CacheConfigBean
public void setMulti(struct mapping, [any Timeout=''], [any LastAccessTimeout=''], [string prefix=''])
mapping
- The structure of name value pairs to cacheTimeout
- 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 keyspublic void setevictionPolicy(AbstractEvictionPolicy evictionPolicy)
evictionPolicy
|
ColdBox Platform Version 2.6.3 | ||||
FRAMES |