### Example HTTP GET Requests for CacheBox Action Commands Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/advanced-usage/cache-reporting/creating-your-own-skins/reporthandler/action-commands.md Illustrates how to invoke various CacheBox action commands using HTTP GET requests, demonstrating the required URL parameters for each command. ```javascript GET monitor.cfm?cbox_command=gc GET monitor.cfm?cbox_command=cacheBoxReapAll GET monitor.cfm?cbox_command=delCacheEntry&cbox_cacheName=default&cbox_cacheEntry=testKey ``` -------------------------------- ### Install CacheBox using CommandBox Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/getting-started/installing-cachebox.md Install the CacheBox library as a dependency in your application using CommandBox. This command fetches either the latest stable version or the bleeding-edge development version. ```bash # Latest Version box install cachebox # Bleeding Edge box install cachebox@be ``` -------------------------------- ### Example Default CacheBox Configuration Structure Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/getting-started/creating-cachebox/README.md This code block provides a detailed example of the default configuration structure for CacheBox. It defines settings for LogBox integration, application scope registration, default cache properties like timeouts, eviction policy, and object store, as well as placeholders for custom caches and event listeners. ```javascript function configure(){ // The CacheBox configuration structure DSL cacheBox = { // LogBox Configuration file logBoxConfig = "cachebox.system.cache.config.LogBox", // Scope registration, automatically register the cachebox factory instance on any CF scope // By default it registers itself on application scope scopeRegistration = { enabled = true, scope = "application", // valid CF scope key = "cacheBox" }, // The defaultCache has an implicit name of "default" which is a reserved cache name // It also has a default provider of cachebox which cannot be changed. // All timeouts are in minutes // Please note that each object store could have more configuration properties defaultCache = { objectDefaultTimeout = 120, objectDefaultLastAccessTimeout = 30, useLastAccessTimeouts = true, reapFrequency = 2, freeMemoryPercentageThreshold = 0, evictionPolicy = "LRU", evictCount = 1, maxObjects = 300, // Our default store is the concurrent soft reference objectStore = "ConcurrentSoftReferenceStore", // This switches the internal provider from normal cacheBox to coldbox enabled cachebox coldboxEnabled = false }, // Register all the custom named caches you like here caches = {}, // Register all event listeners here, they are created in the specified order listeners = [] }; } ``` -------------------------------- ### CacheBox Common Operation Examples (JavaScript) Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/getting-started/creating-cachebox/common-cachefactory-methods.md Illustrative JavaScript examples demonstrating common CacheBox operations such as adding a default cache, setting elements, retrieving caches, removing caches, replacing caches, and initiating a shutdown. ```javascript // Add another default cache type but with the name FunkyCache funkyCache = cachebox.addDefaultCache("FunkyCache"); // Add some elements to funky Cache funkyCache.set("Myentry",now(),"20"); // Get a reference to a named cache cfCache = cacheBox.getCache("CFCache"); // Get a reference to the default named cache cache = cacheBox.getDefaultCache(); // Remove our funky cache no longer needed cacheBox.removeCache("FunkyCache"); // Create a new cache a replace a cache, the MyFunkyFunkyCache implements ICacheProvider newCache = new MyFunkyFunkyCache({maxObjects=200,timeout=30}); // replace the CFCache with this one cacheBox.replaceCache( "CFCache", newCache ); // Add a new cache to cachebox programmatically newCache = new MyFunkyFunkyCache("FunkynessCache", {maxObjects=200,timeout=30}); cacheBox.addCache( newCache ); // Send a shutdown command to cachebox cachebox.shutdown(); ``` -------------------------------- ### CacheBox Advanced Configuration Options Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/getting-started/creating-cachebox/README.md This section provides various ways to configure CacheBox, including using a default constructor, passing a configuration object, using a DSL Simple CFC, or programmatically configuring the CacheBox instance with method chaining. It illustrates flexible setup options. ```javascript // Create CacheBox with default configuration cacheBox = new cachebox.system.cache.CacheFactory( ); // Create CacheBox instance cacheBox = new cachebox.system.cache.CacheFactory( config ); // Create the config object as a CacheBox DSL Simple CFC dataCFC = new MyCacheBoxConfig(); config = new cachebox.system.cache.config.CacheBoxConfig( CFCConfig=dataCFC ); // Create CacheBox instance cacheBox = new cachebox.system.cache.CacheFactory( config ); // Create the config object as a CacheBox DSL Simple CFC path only config = new cachebox.system.cache.config.CacheBoxConfig( CFCConfigPath="MyCacheBoxConfig" ); // Create CacheBox instance cacheBox = new cachebox.system.cache.CacheFactory( config ); // Create CacheBoxConfig, call configuration methods on it and then create the factory config = new cachebox.system.cache.config.CacheBoxConfig(); // Configure programmatically: You can chain methods, woot! config.scopeRegistration( true, "application" ) .defaultCache( objectStore="DiskStore", maxObject=200 ); // Create CacheBox instance cacheBox = new cachebox.system.cache.CacheFactory( config ); ``` -------------------------------- ### Configure CacheBox mapping in ColdFusion Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/getting-started/installing-cachebox.md Define a ColdFusion mapping to the installed CacheBox directory. This mapping ensures that the CacheBox libraries are correctly resolved within your application, especially for standalone installations. ```cfscript this.mappings[ "/cachebox" ] = "path.to.cachebox"; ``` -------------------------------- ### CacheBox Monitor Tag Usage Examples Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/advanced-usage/cache-reporting/README.md Illustrative examples demonstrating various ways to use the custom tag, including specifying a base URL, applying different skins, and integrating it within a ColdBox application's admin view. ```CFML <--- Embedding report in a coldbox application's admin view ---> ``` -------------------------------- ### Instantiate CacheFactory in JavaScript Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/for-the-geeks/cachebox-architecture/cachefactory.md Example demonstrating how to create a new instance of the CacheFactory object using JavaScript, typically for standalone usage outside of a ColdBox application context. ```javascript cachebox = new cachebox.system.cache.CacheFactory(); ``` -------------------------------- ### CacheBoxConfig Object API Methods Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/cachebox-config-object.md API documentation for the `CacheBoxConfig` object, detailing its constructor and configuration methods. These methods allow programmatic configuration of CacheBox, mirroring the DSL items, and are essential for advanced setup. ```APIDOC init([any CFCConfig], [string CFCConfigPath]) Description: The constructor cache(string name, [string provider=], [struct properties={}]) Description: Add a new cache configuration defaultCache([numeric objectDefaultTimeout=], [numeric objectDefaultLastAccessTimeout=], [numeric reapFrequency=], [numeric maxObjects=], [numeric freeMemoryPercentageThreshold=], [boolean useLastAccessTimeouts=], [string evictionPolicy=], [numeric evictCount=], [string objectStore=], [boolean coldboxEnabled=]) Description: Add a default cache configuration listener(string class, [struct properties={}], [string name=]) Description: Add a new listener configuration logBoxConfig(string config) Description: Set the logBox Configuration path to use reset() Description: Reset the entire configuration scopeRegistration([boolean enabled='false'], [string scope='application'], [string key='cachebox']) Description: Use to define cachebox factory scope registration ``` -------------------------------- ### Configure CacheBox Event Listeners Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/cachebox-dsl/README.md Example JavaScript-like configuration for registering event listeners in CacheBox. It demonstrates how to specify the listener class path, a unique name, and any custom properties. ```javascript { // The path to the listener class="path.to.CFC", // A unique name for the listener name="UniqueName", // A structure of name-value pairs for configuring this interceptor properties = {} } { class="Timer", name="CoolTimer" } ``` -------------------------------- ### Configure CacheBox Named Caches Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/cachebox-dsl/README.md Example JavaScript-like configuration for defining named caches within CacheBox. It shows how to specify a provider and various properties like timeout, eviction policy, and object store for a cache. ```javascript // Register all the custom-named caches you like here caches = { sampleCache1 = { provider="cachebox.system.cache.providers.CacheBoxProvider", properties = { objectDefaultTimeout="20", useLastAccessTimeouts="false", reapFrequency="1", evictionPolicy="LFU", evictCount="1", maxObjects="100", objectStore="ConcurrentSoftReferenceStore" } }, sampleCache2 = { provider = "cachebox.system.cache.providers.CFColdboxProvider" } }, ``` -------------------------------- ### Lazy Loading Data into CacheBox with JavaScript Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/for-the-geeks/caching-concepts/cache-loading.md This JavaScript example demonstrates lazy loading data into CacheBox. It first attempts to retrieve data from the cache using a specific key. If the data is not found, it queries the database, stores the result in the cache with a timeout, and then returns the data. This method is ideal for small, frequently accessed content. ```javascript /** * Get some blog categories from the database or cache */ function getCategories(){ var cacheKey = "q-blog-categories"; //Check if data exists local.data = cache.get( cacheKey ); if( !isNull( local.data ) ){ return local.data; } // Else query DB and cache var data = blogDAO.getCategories(); cache.set(cacheKey, data, 120, 20); return data; } ``` -------------------------------- ### Configure LogBox Path for CacheBox Standalone Operation (JavaScript) Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/cachebox-dsl/README.md This snippet shows how to specify the path to a LogBox configuration file within the `logBoxConfig` key. This setting is crucial for standalone CacheBox operations to integrate with a custom LogBox setup. ```javascript // LogBox config path logBoxConfig : "myapp.config.MyLogBoxConfig", ``` -------------------------------- ### Run ColdBox Code Formatting Scripts Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/readme/contributing-guide.md Instructions for using CommandBox scripts to format ColdBox project code. This includes a command for one-time formatting and a watcher command for continuous auto-formatting during development. ```CommandBox box run-script format ``` ```CommandBox box run-script format:watch ``` -------------------------------- ### Initialize CacheBoxConfig and CacheFactory Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/for-the-geeks/cachebox-architecture/cacheboxconfig.md Demonstrates how to instantiate the `CacheBoxConfig` object and then use it to initialize the `CacheFactory`. ```javascript config = new cachebox.system.cache.config.CacheBoxConfig(); cachebox = new cachebox.system.cache.CacheFactory( config ); ``` -------------------------------- ### Create CacheBox with Default Configuration and Set Value Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/getting-started/creating-cachebox/README.md This snippet demonstrates how to initialize CacheBox with its default settings, retrieve the default cache, and then set a value with specific timeout and idle timeout durations. It shows a basic caching operation. ```javascript import cachebox.system.cache.*; // create cachebox cachebox = new CacheFactory(); // get the default cache cache = cachebox.getDefaultCache(); // set a value in cache, with 60 minute timeout and 20 minute idle timeout. cache.set("MyValue", {name="Luis Majano", awesome=true, cacheWeirdo=true}, 60,20); ``` -------------------------------- ### Accessing CacheBox and Cache Providers in ColdBox Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/getting-started/creating-cachebox/README.md This code demonstrates how to retrieve references to the CacheBox instance and various cache providers (default or named) when operating within a ColdBox application, typically via the controller object. ```javascript // Get a reference to CacheBox controller.getCacheBox(); // Get a reference to the default cache provider controller.getCache() or getCache() // Get a reference to a named cache provider controller.getCache("template") or getCache("template") ``` -------------------------------- ### Default Standalone CacheBox Configuration File Path Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/getting-started/creating-cachebox/README.md This snippet shows the default file path where CacheBox's configuration is located when used as a standalone framework. ```javascript /cachebox/system/cache/config/DefaultConfiguration.cfc ``` -------------------------------- ### Default ColdBox Application CacheBox Configuration File Path Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/getting-started/creating-cachebox/README.md This snippet indicates the default file path for CacheBox's configuration when it is used within a ColdBox application, where it is pre-configured. ```javascript /coldbox/system/web/config/CacheBox.cfc ``` -------------------------------- ### CacheFactory Class API Definition Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/for-the-geeks/cachebox-architecture/cachefactory.md Detailed API documentation for the CacheFactory class, outlining its class paths, core responsibilities, and integration within ColdBox and standalone environments. ```APIDOC CacheFactory: class_path: cachebox.system.cache.CacheFactory description: The most important object representing CacheBox, acting as the aggregator and overseer for cache operations. usage_context: - ColdBox: coldbox.system.cache.CacheFactory (auto-configured, linked with LogBox and Intercepting service) - Standalone: cachebox.system.cache.CacheFactory responsibilities: - Get caches - Shutdown caches - Perform global cache operations - Startup CacheBox instance ``` -------------------------------- ### Configure CacheBox Programmatically Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/README.md This snippet demonstrates how to configure CacheBox by instantiating 'cachebox.system.cache.config.CacheBoxConfig' and chaining configuration methods. It then uses this configuration object to initialize a new 'CacheFactory' instance, providing a flexible way to define cache settings. ```cfscript config = new cachebox.system.cache.config.CacheBoxConfig() .scopeRegistration( true ) .defaultCache( maxObjects : 200, objectStore : "ConcurrentStore" ); new cachebox.system.cache.CacheFactory( config ); ``` -------------------------------- ### LogBox Class Definition Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/for-the-geeks/cachebox-architecture/logbox.md Defines the `LogBox` class within the `cachebox.system.logging` package, explaining its role as either a standalone instance or a reference within a ColdBox application. ```APIDOC Class: LogBox Package: cachebox.system.logging Description: A reference to either a new instance of LogBox, if running in standalone mode, or a running LogBox instance via the running ColdBox application context. ``` -------------------------------- ### CacheBox CacheFactory Methods API Reference Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/getting-started/creating-cachebox/common-cachefactory-methods.md Detailed API reference for common methods available in the CacheBox CacheFactory, including parameter types and brief descriptions of their functionality. ```APIDOC CacheFactory Methods: addCache(cache: any) Description: Register a new instantiated cache with this cache factory. addDefaultCache(name: string) Description: Add a default named cache to our registry, create it, config it, register it and return it of type: cachebox. clearAll() Description: Clears all the elements in all the registered caches without de-registrations. configure(config: CacheBoxConfig) Description: Configure the cache factory for operation, called by the init(). expireAll() Description: Expires all the elements in all the registered caches without de-registrations. getCache(name: string) Description: Get a reference to a registered cache in this factory. getDefaultCache() Description: Get the default cache provider of type cachebox. reapAll() Description: A nice way to call reap on all registered caches. removeCache(name: string) Description: Try to remove a named cache from this factory. replaceCache(cache: any, decoratedCache: any) Description: Replace a registered named cache with a new decorated cache of the same name. shutdown() Description: Recursively sends shutdown commands to all registered caches and cleans up in preparation for shutdown. ``` -------------------------------- ### IColdboxApplicationCache Interface Definition Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/for-the-geeks/cachebox-architecture/icoldboxapplicationcache.md Defines the `IColdboxApplicationCache` interface, which extends the base cache provider interface and specifies methods required for ColdBox application caching, including event/view caching, regex-based clearing, and reporting. Implementations must adhere to this contract. ```APIDOC Interface: IColdboxApplicationCache Full Path: cachebox.system.cache.IColdboxApplicationCache Description: This interface extends from the original cache provider interface and adds certain methods that MUST be implemented so the cache can work for ColdBox applications. This includes functionality to do event/view caching, clearing/expiring by certain regular expressions and reporting. So if you want to create your own cache implementation for ColdBox applications, then it must adhere to this contract. ``` -------------------------------- ### ColdBox CacheBox DSL Configuration for External File Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/coldbox-configuration.md This snippet demonstrates how to configure CacheBox using the inline 'cacheBox' DSL within the Coldbox.cfc configuration file. It shows how to specify an external configuration CFC using the 'configFile' key. ```CFML cacheBox = { configFile = "mypath.config.CacheBoxConfig" }; ``` -------------------------------- ### CacheBox Configuration Properties Reference Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/cachebox-dsl/README.md Detailed documentation for various configuration properties available in CacheBox, including their types, descriptions, and default behaviors. These properties control cache behavior, object lifecycles, eviction strategies, and storage mechanisms. ```APIDOC objectDefaultTimeout: type: numeric description: The default lifespan of an object in minutes. This is how long an object lives within the cache. If this value is 0 then all objects will be eternal, meaning they will live forever. objectDefaultLastAccessTimeout: type: numeric description: The default last access or idle timeout in minutes. If an object has not been accessed within this time limit since the last access, then it will be marked for purging. useLastAccessTimeouts: type: boolean description: By default, the last access timeout is enabled. You can disable this purging feature if you desire. resetTimeoutOnAccess: type: boolean description: If true, then when cached objects are retrieved their timeout will be reset to its original value thus elongating the survival strategy of the items. Much how session storages work on JEE. The default is false, meaning the timeout will NOT be reset on each access. reapFrequency: type: numeric description: Every CacheBox provider has its own executor service with a reaping task executing under this frequency. This is how often the cache is inspected to purge old/invalid keys. freeMemoryPercentageThreshold: type: numeric description: The numerical percentage threshold of free JVM memory to be available before caching. If the JVM free memory falls below this setting, the cache will run the eviction policies to cache new objects. If you set this value to be 0, there will be no free memory checks. evictionPolicy: type: string description: The eviction policy algorithm to use. available_algorithms: - LFU (Least Frequently Used) - LRU (Least Recently Used) - Default - LIFO (First In First Out) - FIFO (First In First Out) - Custom: You can also build your own and pass the instantiation path in this setting evictCount: type: numeric description: The number of objects to evict once an execution of the policy is requested. You can increase this to make your evictions more aggressive. By default, one object is purged from the cache. However, you can increase it to purge more than one as needed. maxObjects: type: numeric description: The maximum number of objects the cache can have, give or take, expired objects. Once a limit is reached, the cache will start purging objects using the eviction policy and counts. The default is 300. coldboxEnabled: type: boolean description: 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 applies to the default cache ONLY. For standalone mode, ignore this or always set it to false. objectStore: type: string description: Each CacheBox provider can have a strategy of where to store the objects. These are called object stores. The value here is the name of the store. By default, ConcurrentSoftReferenceStore is used. available_stores: BlackHoleStore: Used for mocking. Objects go nowhere! ConcurrentSoftReferenceStore: Objects are kept in a concurrent hashmap but wrapped in a Java SoftReference object, which can sense the JVM's memory. Meaning it can auto-reap if the JVM desires it. ConcurrentStore: Objects are kept in a concurrent hashmap. DiskStore: Objects are stored on disk in a directory of choice. JDBCStore: Objects are stored in a database table of choice. Custom Stores: You can build your own storage ``` -------------------------------- ### Listener Configuration Properties API Reference Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/cachebox-dsl/README.md API documentation for the properties available when configuring a CacheBox event listener. It details the `class` path, `name`, and `properties` struct for custom configuration. ```APIDOC Listener Configuration: class: path - The instantiation path of the listener object to register name: string - The unique name is used for this listener for registration purposes. If no name is provided, we will use the last part of the instantiation path, usually the filename. properties: struct - A structure of name-value pairs of configuration data for the listener declared. ``` -------------------------------- ### Implement CacheBox Listener in Standalone Mode Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/advanced-usage/cachebox-event-model/cache-listeners.md This CFC illustrates a CacheBox listener for standalone deployments, where it operates independently of a ColdBox application. The `configure()` method is crucial here, receiving the `cacheBox` factory instance and `properties` (a structure from the configuration file). It demonstrates listening for `beforeCacheFactoryShutdown` and `afterCacheElementRemoved` events, accessing event data and using a manually retrieved logger. ```ColdFusion component{ function configure(cacheBox,properties){ variables.cacheBox = arguments.cacheBox; variables.properties = arguments.properties; log = variables.cacheBox.getLogBox().getLogger( this ); } function beforeCacheFactoryShutdown(interceptData){ // Do your stuff here. } function afterCacheElementRemoved(interceptData){ var cache = arguments.interceptData.cache; var key = arguments.interceptData.cacheObjectKey; log.info("The cache #cache.getName()# just removed the key -> #key#"); } } ``` -------------------------------- ### CacheBox Skin Template Directory Structure Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/advanced-usage/cache-reporting/creating-your-own-skins/skin-templates.md Illustrates the required directory structure for creating new skin templates within the CacheBox reporting system. New skins are placed inside the `skins` directory under the CacheBox report path. ```javascript /cachebox/system/cache/report/skins/goodness ``` -------------------------------- ### Implement Custom FIFO Eviction Policy in ColdFusion Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/advanced-usage/cachebox-eviction-policies/using-your-own-policy.md This ColdFusion component demonstrates how to create a custom FIFO (First-In, First-Out) eviction policy by extending `cachebox.system.cache.policies.AbstractEvictionPolicy`. It defines an `init` method for constructor injection and an `execute` method to process evictions based on object 'hits' using the cache's indexer. ```ColdFusion Script /** * FIFO Eviction Policy Command */ component extends="cachebox.system.cache.policies.AbstractEvictionPolicy"{ /** * Constructor * @cacheProvider The associated cache provider of type: cachebox.system.cache.ICacheProvider */ FIFO function init( required cacheProvider ){ super.init( arguments.cacheProvider ); return this; } /** * Execute the policy */ function execute(){ var index = ""; // Get searchable index try{ index = getAssociatedCache() .getObjectStore() .getIndexer() .getSortedKeys( "hits", "numeric", "asc" ); // process evictions via the abstract class processEvictions( index ); } catch(Any e){ getLogger().error("Error sorting via store indexer #e.message# #e.detail# #e.stackTrace#."); } } } ``` -------------------------------- ### Configure CacheBox using JavaScript Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/cachebox-config-object.md Demonstrates how to programmatically configure CacheBox using the `CacheBoxConfig` object in JavaScript. This includes setting LogBox configuration, scope registration, default cache settings, defining specific caches, and adding listeners, showcasing method chaining for concise configuration. ```javascript config = new cacheBox.system.cache.config.CacheBoxConfig(); // logbox config & scope chained, yes you can chain any method config.logBoxConfig( "LogBox" ) .scopeRegistration( true, "application", "cacheBox" ); // default cache config.default( maxObjects=500, evictCount=5, objectDefaultTimeout=30 ); // Caches config.cache( "ehCache", "caches.ehCacheProvider", {configFile="ehCache.xml"} ). cache( "template", "cachebox.system.cache.providers.CacheBoxProvider" ); // Listeners config.listener( "myapp.model.MyListener", "FunkyListener", {} ); ``` -------------------------------- ### CacheBox Configuration DSL Structure (APIDOC) Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/cachebox-dsl/README.md Documents the top-level keys available within the `cacheBox` configuration object. It details each key's purpose, whether it's required, and its specific function in configuring CacheBox behavior, including LogBox integration, scope registration, and cache definitions. ```APIDOC cacheBox Configuration Keys: - logBoxConfig: Required: false Description: The instantiation or location of a LogBox configuration file. This is only for standalone operations. - scopeRegistration: Required: false Description: A structure that enables scope registration of the CacheBox factory in either server, cluster, application, or session scope. - defaultCache: Required: true Description: 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: Required: true Description: A structure where you can create more named caches for usage in your CacheBox factory. - listeners: Required: false Description: 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. ``` -------------------------------- ### Default CacheBox Configuration File Path in ColdBox Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/coldbox-configuration.md This snippet provides the file path to the default CacheBox configuration within the ColdBox framework. This file defines the initial 'default' and 'template' caches used for data and event/view caching respectively. ```JavaScript /coldbox/system/web/config/CacheBox.cfc ``` -------------------------------- ### CacheBox Default Cache Configuration Properties (APIDOC) Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/cachebox-dsl/README.md Documents the various configuration properties for the `defaultCache` in CacheBox. It covers settings like `objectDefaultTimeout`, `evictionPolicy`, `maxObjects`, and `objectStore`, explaining their impact on cache management and performance. ```APIDOC defaultCache Properties: - objectDefaultTimeout: Type: integer Description: Default timeout for objects in minutes. - objectDefaultLastAccessTimeout: Type: integer Description: Default last access timeout for objects in minutes. - useLastAccessTimeouts: Type: boolean Description: Whether to use last access timeouts for eviction. - reapFrequency: Type: integer Description: Frequency in minutes for the cache reaper to run. - freeMemoryPercentageThreshold: Type: integer Description: Percentage of free memory threshold before eviction. - evictionPolicy: Type: string Description: The eviction policy to use (e.g., "LRU"). - evictCount: Type: integer Description: Number of objects to evict per reap cycle. - maxObjects: Type: integer Description: Maximum number of objects the cache can hold. - objectStore: Type: string Description: The underlying object store implementation (e.g., "ConcurrentSoftReferenceStore"). - coldboxEnabled: Type: boolean Description: Switches the internal provider to ColdBox enabled CacheBox. ``` -------------------------------- ### Cache Configuration Properties API Reference Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/cachebox-dsl/README.md API documentation for the properties available when configuring a CacheBox named cache. It details the `provider` path and the `properties` struct for custom configuration. ```APIDOC Cache Configuration: provider: string - The path of the cache that must implement our ICacheProvider interface. properties: struct - A structure of name-value pairs of configuration data for the cache to declare. ``` -------------------------------- ### ColdBox Controller Class Definition Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/for-the-geeks/cachebox-architecture/coldbox.md Defines the `coldbox.system.web.Controller` class, which provides access to the ColdBox application context for CacheBox instances. This class is relevant when CacheBox operates within a ColdBox application, enabling `CacheProvider` to interact with the application's components. ```APIDOC Class: coldbox.system.web.Controller Description: A reference to a running ColdBox application context the CacheBox instance is running under. This will be null if running in standalone mode. However, if you are within a ColdBox application, the CacheProvider and its references can access anything within the running ColdBox application. ``` -------------------------------- ### CacheBox Built-in Cache Providers API Reference Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/usage/cache-providers/README.md A reference table detailing the various cache providers shipped with CacheBox, including their ColdBox compatibility, reporting features, and a brief description of each. This outlines the core properties and purpose of each provider. ```APIDOC Cache Providers: - Provider: CacheBoxProvider ColdBox Enabled: false Reporting Enabled: true Description: Our very own CacheBox caching engine - Provider: CacheBoxColdBoxProvider ColdBox Enabled: true Reporting Enabled: true Description: Our CacheBox caching engine prepared for ColdBox application usage - Provider: CFProvider ColdBox Enabled: false Reporting Enabled: true Description: A ColdFusion 9.0.1 and above implementation - Provider: CFColdBoxProvider ColdBox Enabled: true Reporting Enabled: true Description: A ColdBox enhanced version of our ColdFusion 9.0.1 cache provider - Provider: LuceeProvider ColdBox Enabled: false Reporting Enabled: true Description: A ColdBox enhanced version of our Lucee cache provider - Provider: LuceeColdBoxProvider ColdBox Enabled: true Reporting Enabled: true Description: A ColdBox enhanced version of our Lucee cache provider - Provider: MockProvider ColdBox Enabled: true Reporting Enabled: false Description: A ColdBox enhanced cache provider that can be used for mocking or testing ``` -------------------------------- ### CacheBox Skin Template Files Reference Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/advanced-usage/cache-reporting/creating-your-own-skins/skin-templates.md Details the purpose and requirements of the various template files used in CacheBox skinning. These templates are rendered by the `ReportHandler.cfc` and allow for customization of the cache report monitor, including JavaScript, CSS, and ColdFusion Markup Language (CFML) components. ```APIDOC cachebox.js: Required: true Description: The JavaScript file that will be automatically loaded into the header content via a cfhtmlhead call. You can put any JavaScript you like here or load more JavaScript files via your skin templates. cachebox.css: Required: true Description: The css file that will be automatically loaded into the header content via a cfhtmlhead call. CachePanel.cfm: Required: true Description: The main template that displays the report monitor to the user. This skin could potentially hold action buttons and other parts of the cache report rendered in specific locations by using rendering methods (see ReportHandler section). CacheReport.cfm: Required: false Description: This template is usually rendered via the renderCacheReport(cacheName) method and it is supposed to render out a report of the cache provider using the incoming cacheName argument. This template usually has a call somewhere for the content report of such cache provider via the renderCacheContentReport(cacheName) method. CacheContentReport.cfm: Required: false Description: This template is usually rendered via the renderCacheContentReport(cacheName) method and it is supposed to render out a report of the contents of the cache provider using the incoming cacheName argument. This table of contents can also have action buttons assigned to them. ``` -------------------------------- ### CacheBox Reporting Skin Location Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/advanced-usage/cache-reporting/creating-your-own-skins/README.md This snippet indicates the default directory path where custom CacheBox reporting skins should be placed within the project structure. Each skin resides in a uniquely named subfolder within this directory. ```javascript /cachebox/system/cache/report/skins ``` -------------------------------- ### CacheBox Action Commands API Reference Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/advanced-usage/cache-reporting/creating-your-own-skins/reporthandler/action-commands.md Defines the available action commands for CacheBox monitoring tags, including their purpose and required URL parameters. Commands are triggered via the 'URL.cbox_command' variable. ```APIDOC Command: expireCache Description: Executes a expireAll() in the cache provider specified by the incoming cache name. Parameters: url.cbox_cacheName: The name of the cache provider. Command: reapCache Description: Executes a reap() in the cache provider specified in the incoming cache name. Parameters: url.cbox_cacheName: The name of the cache provider. Command: delCacheEntry Description: Deletes the passed in cache entry from the named provider. Parameters: url.cbox_cacheName: The name of the cache provider. url.cbox_cacheEntry: The key of the cache entry to delete. Command: clearAllEvents Description: Executes a clearAllEvents() in the cache provider specified in the incoming cache name (Must be a ColdBox enabled cache). Parameters: url.cbox_cacheName: The name of the cache provider. Command: clearAllViews Description: Executes a clearAllViews() in the cache provider specified in the incoming cache name (Must be a ColdBox enabled cache). Parameters: url.cbox_cacheName: The name of the cache provider. Command: cacheBoxReapAll Description: Executes a reapAll() via the CacheBox Cache Factory. Parameters: none Command: cacheBoxExpireAll Description: Executes a expireAll() via the CacheBox Cache Factory. Parameters: none Command: gc Description: Executes a suggestion to the JVM to produce a garbage collection. Parameters: none ``` -------------------------------- ### CacheBox Scope Registration Configuration (APIDOC) Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/cachebox-dsl/README.md Details the properties available for configuring CacheBox's automatic scope registration. It outlines each property's type, whether it's required, its default value, and a description of its function. ```APIDOC scopeRegistration Properties: - enabled: Type: boolean Required: false Default: true Description: Enable scope registration - scope: Type: string Required: false Default: application Description: The ColdFusion scope to persist on - key: Type: string Required: false Default: cachebox Description: The name of the key in the ColdFusion scope to persist on ``` -------------------------------- ### Configure Default Cache Settings for CacheBox (JavaScript) Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/cachebox-dsl/README.md Illustrates the comprehensive configuration options for the `defaultCache` in CacheBox. This includes settings for object timeouts, eviction policies, memory thresholds, and the underlying object store, allowing fine-grained control over cache behavior. ```javascript // The defaultCache has an implicit name of "default" which is a reserved cache name // It also has a default provider of cachebox which cannot be changed. // All timeouts are in minutes // Please note that each object store could have more configuration properties defaultCache : { objectDefaultTimeout : 120, objectDefaultLastAccessTimeout : 30, useLastAccessTimeouts : true, reapFrequency : 2, freeMemoryPercentageThreshold : 0, evictionPolicy : "LRU", evictCount : 1, maxObjects : 300, objectStore : "ConcurrentSoftReferenceStore", // This switches the internal provider from normal cacheBox to coldbox enabled cachebox coldboxEnabled : false }, ``` -------------------------------- ### Configure CacheBox using a Struct Literal Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/README.md This snippet illustrates an alternative configuration method where CacheBox is initialized directly with a struct literal. This struct defines various cache settings, including 'logBoxConfig', 'scopeRegistration', and 'defaultCache' properties, which are then passed to the 'CacheFactory' constructor. ```cfscript new cachebox.system.cache.CacheFactory( { // LogBox Configuration file logBoxConfig : "coldbox.system.cache.config.LogBox", // Scope registration, automatically register the cachebox factory instance on any CF scope // By default it registers itself on server scope scopeRegistration : { enabled : true, scope : "application", // the cf scope you want key : "cacheBox" }, // The defaultCache has an implicit name of "default" which is a reserved cache name // It also has a default provider of cachebox which cannot be changed. // All timeouts are in minutes // Please note that each object store could have more configuration properties defaultCache : { objectDefaultTimeout : 120, objectDefaultLastAccessTimeout : 30, useLastAccessTimeouts : true, reapFrequency : 2, freeMemoryPercentageThreshold : 0, evictionPolicy : "LRU", evictCount : 1, maxObjects : 300, objectStore : "ConcurrentSoftReferenceStore", // This switches the internal provider from normal cacheBox to coldbox enabled cachebox coldboxEnabled : false } } ); ``` -------------------------------- ### DiskStore Configuration Properties Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/usage/cachebox-object-stores/diskstore.md Defines the configurable properties for the `DiskStore` component, including options for automatic path expansion and the required directory path for storing cached objects. ```APIDOC DiskStore Properties: autoExpandPath: Type: Boolean Required: false Default: true Description: A flag that indicates if the store should use expandPath() to figure out the path to store objects in. directoryPath: Type: string Required: true Default: --- Description: The directory path to use to store cached objects under. This can be relative or absolute. ``` -------------------------------- ### Default CacheBox Configuration Component in CFScript Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/README.md This code snippet illustrates the default configuration applied when CacheBox is initialized without explicit settings. It defines a ColdFusion component with a `configure` function that sets up the `cacheBox` structure, including LogBox integration, application scope registration, and properties for the `defaultCache` such as timeouts, eviction policy, and object store type. This serves as the baseline for CacheBox's operation. ```CFScript /** * Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp * www.ortussolutions.com * ---- * The default ColdBox CacheBox configuration object that is used when the cache factory is created by itself **/ component { /** * Configure CacheBox, that's it! */ function configure(){ // The CacheBox configuration structure DSL cacheBox = { // LogBox Configuration file logBoxConfig : "coldbox.system.cache.config.LogBox", // Scope registration, automatically register the cachebox factory instance on any CF scope // By default it registers itself on server scope scopeRegistration : { enabled : true, scope : "application", // the cf scope you want key : "cacheBox" }, // The defaultCache has an implicit name of "default" which is a reserved cache name // It also has a default provider of cachebox which cannot be changed. // All timeouts are in minutes // Please note that each object store could have more configuration properties defaultCache : { objectDefaultTimeout : 120, objectDefaultLastAccessTimeout : 30, useLastAccessTimeouts : true, reapFrequency : 2, freeMemoryPercentageThreshold : 0, evictionPolicy : "LRU", evictCount : 1, maxObjects : 300, objectStore : "ConcurrentSoftReferenceStore", // This switches the internal provider from normal cacheBox to coldbox enabled cachebox coldboxEnabled : false }, // Register all the custom named caches you like here caches : {}, // Register all event listeners here, they are created in the specified order listeners : [ // { class="", name="", properties={} } ] }; } } ``` -------------------------------- ### Basic CacheBox Monitor Tag Usage Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/advanced-usage/cache-reporting/README.md This snippet demonstrates how to import the CacheBox custom tag library, initialize a CacheBox factory instance, and use the tag to render a cache report within a ColdFusion Markup Language (CFML) page. ```CFML <--- Create CacheBox with default configuration ---> CacheBox Monitor Tool <--- Special ToolBar --->
<--- Render Report Here --->
``` -------------------------------- ### CFProvider-CFColdboxProvider Events API Reference Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/advanced-usage/cachebox-event-model/provider-events.md Detailed API documentation for events triggered by the CFProvider-CFColdboxProvider, including event names, associated data, and descriptions. ```APIDOC Event: afterCacheElementInsert Description: Called after a new cache element has been inserted into the cache Data: cache: the cache provider cacheObject: the new object to cache cacheObjectKey: the key used to store the object cacheObjectTimeout: the timeout used cacheObjectLastAccessTimeout: the last access timeout used Event: afterCacheElementRemoved Description: Called after a cache element has been removed from the cache Data: cache: the cache provider cacheObjectKey: the key of the removed object Event: afterCacheClearAll Description: Called after a `clearAll()` has been issued on the cache Data: cache: the cache provider ``` -------------------------------- ### EventManager Class Definition Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/for-the-geeks/cachebox-architecture/eventmanager.md Defines the class paths for the EventManager in CacheBox, indicating its similarity to ColdBox's Interceptor Service. ```APIDOC class : cachebox.system.core.events.EventPoolManager or coldbox.system.web.services.InterceptorService ``` -------------------------------- ### CacheBox Configuration DSL for Default Cache Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/configuration/cachebox-configuration/cachebox-dsl/default-cache.md This JavaScript snippet demonstrates the CacheBox configuration DSL, specifically defining the 'defaultCache' settings. It includes properties for object timeouts, eviction policy (LRU), maximum objects, and specifies the 'ConcurrentSoftReferenceStore' as the default object store. It also highlights that more configuration properties can be added for specific object stores. ```javascript // The CacheBox configuration structure DSL cacheBox = { // Please note that each object store could have more configuration properties defaultCache = { objectDefaultTimeout = 60, objectDefaultLastAccessTimeout = 30, useLastAccessTimeouts = true, reapFrequency = 2, freeMemoryPercentageThreshold = 0, evictionPolicy = "LRU", evictCount = 1, maxObjects = 200, // Our default store is the concurrent soft reference objectStore = "ConcurrentSoftReferenceStore", // This switches the internal provider from normal cacheBox to coldbox enabled cachebox coldboxEnabled = false, resetTimeoutOnAccess = false } }; ``` -------------------------------- ### CacheBox Provider Eviction Policies Source: https://github.com/ortus-docs/cachebox-docs/blob/v7.x/usage/cache-providers/cachebox-provider.md Available eviction policy algorithms for the CacheBox Provider, including standard policies like LRU, LFU, FIFO, LIFO, and support for custom implementations. ```APIDOC Eviction Policies: - LRU (Least Recently Used) - LFU (Least Frequently Used) - FIFO (First In First Out) - LIFO (Last In First Out) - Custom: You can also build your own and pass the instantiation path in this setting ```