> For the complete documentation index, see [llms.txt](https://bxorm.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bxorm.ortusbooks.com/bxorm-2.x/getting-started/configuration/secondary-caches.md).

# Secondary Caches

Turn on the second-level cache and pick where its regions live

The second-level cache keeps entities, collections and query results across sessions and requests. In bx-orm 2 it is backed by BoxLang's own BoxCache: every cache region is a BoxLang cache. See [Caching](/bxorm-2.x/advanced/caching.md) for the full guide, including strategies, collection and query caching, and tuning each region.

## Settings

| Setting                 | Default              | Description                                                                                                                                                                               |
| ----------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `secondaryCacheEnabled` | `false`              | Turns the second-level cache on.                                                                                                                                                          |
| `cacheProvider`         | `"BoxCacheProvider"` | The BoxLang cache provider for the caches bx-orm creates. `ConcurrentHashMap`, `HashTable` and `ehcache` are aliases for BoxCache; any other value must be a registered BoxLang provider. |
| `cacheConfig`           | *empty*              | BoxCache properties for the regions: a struct (top-level keys for every region, `regions` for one region), or the path of a JSON file or an EHCache 2 or 3 `ehcache.xml`.                 |

```js
this.ormSettings = {
    secondaryCacheEnabled : true,
    cacheConfig           : {
        maxObjects : 1000,
        regions    : { "countries" : { defaultTimeout : 0 } }
    }
};
```

A BoxLang cache that already exists with a region's name (for example one defined in `boxlang.json`) is used for that region as is. See [Using Your Own BoxLang Caches](/bxorm-2.x/advanced/caching.md#using-your-own-boxlang-caches).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://bxorm.ortusbooks.com/bxorm-2.x/getting-started/configuration/secondary-caches.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
