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

# Caching Layer Integration Documentation

> Feature ID: PF-51 Version: 1.0 Last Updated: 2026-03-04 Status: ✅ Complete — 2026-03-05

**Feature ID:** PF-51\
**Version:** 1.0\
**Last Updated:** 2026-03-04\
**Status:** ✅ Complete — 2026-03-05

***

## Overview

This document describes how PF-51 (Caching Layer & Strategy) integrates with the platform. The caching layer provides a centralized, tenant-scoped cache for query results, configuration, and reference data. All cores consume it via the Platform Integration Layer (`@/platform/cache`); there are no cross-core dependencies.

***

## Integration Pattern

**Pattern Type:** Platform Integration Layer (Pattern 1)

PF-51 provides:

* **Caching service:** `get`, `set`, `delete`, `clear`/`invalidate` with tenant-scoped keys
* **Cache hooks:** `useCachedQuery` integrated with TanStack Query
* **Invalidation:** Pattern-based and user-scoped invalidation; optional event-based invalidation

No events are published by PF-51. Other modules may call the cache invalidate API or subscribe to optional platform events for cache invalidation.

***

## Public API

**Location:** `src/platform/cache/`

| Export           | Purpose                                                     |
| ---------------- | ----------------------------------------------------------- |
| `cacheService`   | `get`, `set`, `delete`, `clear`, `invalidate`               |
| `useCachedQuery` | TanStack Query–backed cached query hook                     |
| Cache key format | `org-{orgId}:{namespace}:{key}` (organization\_id required) |

See the spec `specs/pf/specs/PF-51-caching-layer-strategy.md` for full API Design and FR-1/FR-2/FR-3.

***

## Consumer Cores

All cores may use `@/platform/cache` for:

* Query result caching (via `useCachedQuery` or direct service)
* Configuration caching (org settings, preferences)
* Reference data caching (picklists, custom field definitions)

**Tenant isolation:** All cache keys MUST include `organization_id`. Helpers obtain/inject current org when callers omit it; missing org id causes validation failure.

***

## Integration Matrix

This integration is referenced in:

* [PLATFORM\_INTEGRATION\_LAYERS.md](./PLATFORM_INTEGRATION_LAYERS.md) — Quick Reference table
* [CROSS\_CORE\_INTEGRATIONS.md](./CROSS_CORE_INTEGRATIONS.md) — PF-51 | All Cores | Platform Layer

***

## References

* **Spec:** `specs/pf/specs/PF-51-caching-layer-strategy.md`
* **Plan:** `specs/pf/plans/PF-51-caching-layer-PLAN.md` (when created)
