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

# Caching

> Redis cache keys and TTLs (technical reference).

<Note>
  Intended for contributors and technical readers.
</Note>

PilotWatt uses **Upstash Redis** (not in-process memory) so serverless instances share cache.

| Key pattern                                   | TTL          | Contents                                              |
| --------------------------------------------- | ------------ | ----------------------------------------------------- |
| `foxess:state:{userId}`                       | 5 min        | Live energy state                                     |
| `foxess:schedule:{userId}`                    | 60 s         | FoxESS Mode Scheduler get (invalidated on write)      |
| `scheduler:drift-check:{userId}`              | 15 min       | Gate for full inverter drift repair on home load      |
| `octopus:rates` / IO window                   | 30 min       | Agile slots and Intelligent Octopus window            |
| `solar:forecast:v2:{userId}`                  | 1 h          | Hourly radiation + kWh                                |
| `recommendation:v2:{userId}`                  | 30 min       | Optimiser result                                      |
| `earnings:today/month/slots/summary:{userId}` | 30 min – 7 d | Earnings aggregates (month 1 h; historical slots 7 d) |
| `settings:public:{userId}`                    | 5 min        | Non-secret settings only                              |
| `foxess:import-history:{userId}`              | 24 h         | Grid import history for EV detection                  |
| `alpha:spots-remaining`                       | 5 min        | Alpha capacity banner                                 |

**Never cached:** decrypted FoxESS / Octopus credentials.

Source of truth: `lib/infrastructure/cache.ts`.
