# Provider Events

Each cache provider has the potential of announcing life cycle events as it implements it. If you are a cache provider author, then you can use the aggregated `EventManager` to register, process and announce events a-la-carte. So let's investigate each provider's life cycle events:

## CacheBoxProvider-CacheBoxColdBoxProvider Events

| Event                    | Data                                                                                                                                                                                                                                                                                                                                   | Description                                                                                                          |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| afterCacheElementUpdated | <p><strong>cache</strong>: the cache provider<br><br><strong>cacheNewObject</strong>: the new object to cache<br><br><strong>cacheOldObject</strong>: the object replaced</p>                                                                                                                                                          | Called via a `set()` operation when there is already the same key in the cache. Called before the replacement occurs |
| afterCacheElementInsert  | <p><strong>cache</strong>: the cache provider<br><br><strong>cacheObject</strong>: the new object to cache<br><br><strong>cacheObjectKey</strong>: the key used to store the object<br><br><strong>cacheObjectTimeout</strong>: the timeout used<br><br><strong>cacheObjectLastAccessTimeout</strong>:the last access timeout used</p> | Called after a new cache element has been inserted into the cache                                                    |
| afterCacheElementRemoved | <p><strong>cache</strong>: the cache provdier<br><br><strong>cacheObjectKey</strong>: the key of the removed object</p>                                                                                                                                                                                                                | Called after a cache element has been removed from the cache                                                         |
| afterCacheClearAll       | **cache**: the cache provider                                                                                                                                                                                                                                                                                                          | Called after a `clearAll()` has been issued on the cache                                                             |
| afterCacheElementExpired | <p><strong>cache</strong>: the cache provider<br><br><strong>cacheObjectKey</strong>: the key of the expired object</p>                                                                                                                                                                                                                | Called after a cache element has been expired from the cache                                                         |

## CFProvider-CFColdboxProvider Events

| Event                    | Data                                                                                                                                                                                                                                                                                                                                      | Description                                                       |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| afterCacheElementInsert  | <p><strong>cache</strong>: the cache provider<br><br> <strong>cacheObject</strong>: the new object to cache<br><br> <strong>cacheObjectKey</strong>: the key used to store the object<br><br><strong>cacheObjectTimeout</strong>: the timeout used<br><br><strong>cacheObjectLastAccessTimeout</strong>: the last access timeout used</p> | Called after a new cache element has been inserted into the cache |
| afterCacheElementRemoved | <p><strong>cache</strong>: the cache provider<br><br> <strong>cacheObjectKey</strong>: the key of the removed object</p>                                                                                                                                                                                                                  | Called after a cache element has been removed from the cache      |
| afterCacheClearAll       | **cache**: the cache provider                                                                                                                                                                                                                                                                                                             | Called after a `clearAll()` has been issued on the cache          |


---

# 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/5.x-1/advanced-usage/cachebox-event-model/provider-events.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.
