> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monocle.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Cache

> Monitor cache hit rates, latency, and per-key performance

Monocle provides a dedicated Cache dashboard for monitoring your cache layer. See how your cache is performing at a glance and identify which keys need attention.

## What Monocle tracks

* **Hit rate** with color-coded percentage (green for healthy, red for low)
* **Total operations** count and average/P95 latency
* **Hit/miss chart** showing cache efficiency over time
* **Latency chart** tracking response time trends
* **Per-key breakdown** with individual hit/miss ratio and latency metrics

## Key sanitization

Cache keys often contain dynamic values (user IDs, UUIDs, session tokens) that would create high-cardinality attributes. Monocle automatically sanitizes keys by replacing dynamic segments with `*`:

* `users:550e8400-e29b-41d4-a716-446655440000` becomes `users:*`
* `post:12345` becomes `post:*`
* `hash:a1b2c3d4e5f6` becomes `hash:*`

This keeps the per-key table useful instead of showing thousands of unique entries. You can provide a custom sanitizer if the defaults do not match your key format.

## Span attributes

All cache instrumentations must emit these attributes for the Cache dashboard to work correctly.

| Attribute         | Dashboard Feature                                                  |
| ----------------- | ------------------------------------------------------------------ |
| `cache.operation` | Operation type grouping (`get`, `set`, `getOrSet`, `delete`, etc.) |
| `cache.key`       | Per-key breakdown table (sanitized)                                |
| `cache.hit`       | Hit rate calculation and hit/miss charts                           |
| `cache.store`     | Cache store identification                                         |

## Supported libraries

<CardGroup cols={1}>
  <Card title="Bentocache" icon="bolt" href="/instrumentations/bentocache">
    Multi-tier caching library for Node.js. Instrumentation provided by `@bentocache/otel`.
  </Card>
</CardGroup>

## Getting started

See the [AdonisJS guide](/frameworks/adonisjs#cache) for setup instructions if you are using AdonisJS.
