---
title: "Key behavior cache"
slug: "key-behavior-cache"
abstract: "An overview of the key behavior cache facet's configuration options and calculation logic."
---
# Key behavior cache

> [!note]
> The `KeyBehaviorCache` class has been deprecated but will be reinstated in a future release. You can use this class even though it is currently marked as obsolete.

The key behavior cache is a calculated facet that stores information about a contact’s most recently triggered events. The key behavior cache facet is represented by the `Sitecore.XConnect.Collection.Model.KeyBehaviorCache` class.

<details>
<summary><h2>Calculation logic</h2></summary>

The following table describes where the data each list of `Sitecore.XConnect.Collection.Model.KeyBehaviorCacheEntry` comes from:

| **Property** | **Calculation logic** |
| --- | --- |
| `Campaigns` | Taken from interaction’s `Events` property where event is of type `CampaignEvent`, and from the interaction’s `CampaignId` property. |
| `Goals` | Taken from interaction’s `Events` property where event is of type `Goal`. |
| `Channels` | Taken from the interaction’s `ChannelId` property. |
| `Outcomes` | Taken from interaction’s `Events` property where event is of type `Outcome`. |
| `PageEvents` | Taken from interaction’s `Events` property where the `ParentEventId` is the ID of a `PageEvent`, and the event is not an `Outcome` or `Goal`. |
| `Venues` | Taken from the interaction’s `VenueId` property. |
| `CustomValues` | Not currently set. |

Entries are trimmed from each list if:

- The associated interaction falls outside the configured maximum time period (for example, 30 days)
- The maximum number of list cache entries has been exceeded - the oldest cache entries are trimmed
- The number of unique interactions represented by all cache entries exceeds the maximum - the oldest cache entries are trimmed

> [!note]
> If the maximum interaction count is 25 and each cache entry is represented by a unique interaction, the list is limited to 25 entries even if the maximum cache entry count is 50.

</details>

<details>
<summary><h2>Configuring the key behavior cache</h2></summary>

The following configuration options are defined in two locations in the `\App_data\config\sitecore\Collection\sc.XConnect.Collection.Model.Plugins.xml`. You must update the configuration values in both locations:

- `<IContactMergeHandler.KeyBehaviorCacheHandler>`
- `<ICalculatedFacetHandler.KeyBehaviorCacheHandler>`

| Element | Description |
| --- | --- |
| `MaximumCacheEntryCount` | Specifies the maximum number of items in the cache for a given category, such as goals, page events, and so on.<br><br>The default value is 50 entries. |
| `MaximumInteractionPeriod` | Specifies the maximum period for interactions that xDB uses during updates.<br><br>The default value is 30 days. |
| `MaximumInteractionCount` | Specifies the maximum number of interactions that xDB examines during updates.<br><br>The default value is 25 interactions. |

</details>