# CacheBox Config Object

The previous CacheBox DSL is a great way to configure CacheBox as it is very portable. However, you can also configure CacheBox by calling methods on the CacheBoxConfig object, which is exactly what we do when we read the CacheBox DSL.

Below are the main methods used for configuring CacheBox which match exactly to the DSL items, so please refer to the DSL items for definitions and settings. Also, for all the methods in this object, check out the [API Docs](http://apidocs.ortussolutions.com/cachebox/current)

* `init([any CFCConfig], [string CFCConfigPath])`

The constructor

* `cache(string name, [string provider=], [struct properties={}])`

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=])`

Add a default cache configuration

* `listener(string class, [struct properties={}], [string name=])`

Add a new listener configuration

* `logBoxConfig(string config)`

Set the logBox Configuration path to use

* `reset()`

Reset the entire configuration

* `scopeRegistration([boolean enabled='false'], [string scope='application'], [string key='cachebox'])`

Use to define cachebox factory scope registration

## Code Examples:

```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", {} );
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cachebox.ortusbooks.com/2.1.0/cachebox-configuration/cachebox-config-object.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
