The caches element is in itself a structure of configuration data for aggregating named cache providers of ANY type. The key is the unique name of the cache to aggregate under this CacheBox instance. The value should be a structure with the following keys:
Example:
This is an array of structures that you will use to define cache listeners. This is exactly the same as if you would be declaring ColdBox Interceptors, so order is very important. The order of declaration is the order that they are registered into their specific listening events and also the order in which they fire. The keys to declare for each structure are:
In order to create a simple data CFC, just create a new CFC with one required method on it called configure()
. This is where you will define the caching configuration data structure in a structure called cacheBox
in the variables
scope:
The cacheBox structure can be configured with the following keys:
CacheBox has a nifty little feature that enables itself to leech onto a specific scope in memory. It basically can auto-register itself in your environment with no further need for persistence or just to expand its location. By default CacheBox registers itself in application scope with a key of cacheBox, but you have complete control on how the scope registration should work.
Example:
The defaultCache
element is in itself a structure of configuration data for the default cache provider of type cachebox.system.cache.providers.CacheBoxProvider
. This is a reserved cache name and it is MANDATORY to declare and its name or type cannot be changed.
However, if you are using CacheBox within a ColdBox application, the provider will switch itself to cachebox.system.cache.providers.CacheBoxColdBoxProvider
by using the coldboxEnabled
key. So let's see the configuration keys for our default cache.
LFU (Least Frequently Used)
LRU (Least Recently Used)
FIFO (First In First Out)
Custom: You can also build your own and pass the instantiation path in this setting
ConcurrentStore - Uses concurrent hashmaps for increased performance
ConcurrentSoftReferenceStore - Concurrent hashmaps plus java soft references for JVM memory sensitivity
DiskStore - Uses a physical disk location for caching (Uses java serialization for complex objects)
JDBCStore - Uses a JDBC datasource for caching (Uses java serialization for complex objects)
Custom : You can also build your own and pass the instantiation path in this setting.
Caution : Please note that each object store could have more configuration properties that you will need to add to the configuration structure. To find out about these extra configuration properties, please see the Object Store's section.
Example:
Key
Type
Required
Default
Description
provider
string
true
---
The instantiation path of the cache that must implement our ICacheProvider
interface.
properties
struct
false
{}
A structure of name-value pairs of configuration data for the cache to declare.
Key | Type | Required | Default | Description |
class | instantiation path | true | --- | The instantiation path of the listener object to register |
name | string | false |
| The unique name used for this listener for registration purposes. If no name is provided, then we will use the last part of the instantiation path, which is usually the filename. |
properties | struct | false |
| A structure of name-value pairs of configuration data for the listener declared. |
Key | Type | Required | Default | Description |
ObjectDefaultTimeout | numeric | false | 60 | The default lifespan of an object in minutes |
ObjectDefaultLastAccessTimeout | numeric | false | 30 | The default last access or idle timeout in minutes |
UseLastAccessTimeouts | Boolean | false | true | Use or not idle timeouts |
ReapFrequency | numeric | false | 2 | The delay in minutes to produce a cache reap (Not guaranteed) |
FreeMemoryPercentageThreshold | numeric | false | 0 | The numerical percentage threshold of free JVM memory to have available before caching. If the JVM free memory falls below this setting, the cache will run the eviction policies in order to cache new objects. (0=Unlimited) |
MaxObjects | numeric | false | 200 | The maximum number of objects for the cache |
EvictionPolicy | string or path | false | LRU | The eviction policy algorithm class to use. |
EvictCount | numeric | false | 1 | The number of objects to evict once an execution of the policy is requested. You can increase this to make your evictions more aggressive |
objectStore | string | false | ConcurrentStore | The object store to use for caching objects. |
ColdBoxEnabled | Boolean | false | false | A flag that switches on/off the usage of either a plain vanilla CacheBox provider or a ColdBox enhanced provider. This must be true when used within a ColdBox application and it applies for the default cache ONLY. |
resetTimeoutOnAccess | boolean | false | false | If true, then when cached objects are retrieved their timeout will be reset to its original value and thus elongating the survival strategy of the items. Much how session storages work. |
Key | Type | Required | Default | Description |
logBoxConfig | string | false |
| The instantiation or location of a LogBox configuration file. This is only for standalone operation. |
scopeRegistration | struct | false |
| A structure that enables scope registration of the CacheBox factory in either server, cluster, application or session scope. |
defaultCache | struct | true | --- | The configuration of the default cache which will have an implicit name of default which is a reserved cache name. It also has a default provider of CacheBox which cannot be changed. |
caches | struct | true |
| A structure where you can create more named caches for usage in your CacheBox factory. |
listeners | array | false |
| An array that will hold all the listeners you want to configure at startup time for your CacheBox instance. If you are running CacheBox within a ColdBox application, this item is not necessary as you can register them via the main ColdBox interceptors section. |
Key | Type | Required | Default | Description |
enabled | boolean | false | true | Enable scope registration |
scope | string | false | application | The ColdFusion scope to persist on |
key | string | false | cachebox | The name of the key in the ColdFusion scope to persist on |
The LogBoxConfig element is used only in standalone mode of operation and tells CacheBox what configuration file to load into LogBox. LogBox is an enterprise ColdFusion (CFML) logging library. This way, you have granular control of how CacheBox and its registered caches will be producing logging and debugging data. If you do not specify a location for a custom LogBox configuration file, then CacheBox will instantiate LogBox with its own default configuration file located at:
Example