---
id: "cache-as-primary-store-without-persistence"
type: "rule"
severity: "error"
url: "https://localhost:3000/catalogue/rules/cache-as-primary-store-without-persistence"
---

# Cache used as primary store without persistence

A cache is the only copy of its data and has persistence disabled, so the data is lost on restart.

| | |
|---|---|
| Severity | error |
| Selects | every node of kind cache |
| Components in scope | 37 |

## Why

This cache is the only copy of its data and has persistence turned off. A restart loses the data outright.

## What it checks

It looks at every node of kind cache, and fires when:

- all of these hold:
  - the node's `usedAsPrimaryStore` is true
  - the node's `persistence` is false

Message template:

```
Cache '{{node.id}}' is the primary store for its data but has persistence disabled.
```

## Applies to

- [Cache](https://localhost:3000/catalogue/kinds/cache.md) `cache`

37 catalogue components fall under it.

## Tripped by

Reference designs whose broken twin names this rule in its header:

- [airbnb-search](https://localhost:3000/d/zeema/airbnb-search)
- [cloudflare-edge](https://localhost:3000/d/zeema/cloudflare-edge)
- [datadog-husky](https://localhost:3000/d/zeema/datadog-husky)
- [digital-wallet](https://localhost:3000/d/zeema/digital-wallet)
- [dropbox-sync](https://localhost:3000/d/zeema/dropbox-sync)
- [duolingo-backend](https://localhost:3000/d/zeema/duolingo-backend)
- [gitlab-architecture](https://localhost:3000/d/zeema/gitlab-architecture)
- [google-maps](https://localhost:3000/d/zeema/google-maps)
- [hotstar-streaming](https://localhost:3000/d/zeema/hotstar-streaming)
- [instagram-feed](https://localhost:3000/d/zeema/instagram-feed)
- [khan-academy-goliath](https://localhost:3000/d/zeema/khan-academy-goliath)
- [netflix-streaming](https://localhost:3000/d/zeema/netflix-streaming)
- [proximity-service](https://localhost:3000/d/zeema/proximity-service)
- [snapchat-platform](https://localhost:3000/d/zeema/snapchat-platform)
- [stack-overflow](https://localhost:3000/d/zeema/stack-overflow)
- [tiktok-recommendation](https://localhost:3000/d/zeema/tiktok-recommendation)
- [twitter-timeline](https://localhost:3000/d/zeema/twitter-timeline)
- [wikipedia](https://localhost:3000/d/zeema/wikipedia)
- [x-recommendation](https://localhost:3000/d/zeema/x-recommendation)
- [zerodha-kite](https://localhost:3000/d/zeema/zerodha-kite)

## Source (`rule` YAML, verbatim)

```yaml
# yaml-language-server: $schema=../schema/rule.schema.json
# A cache used as the only copy of data, with persistence off, loses that data on restart.
# Tripped by: designs/twitter-timeline.broken.yaml
schemaVersion: "1"
type: "rule"
id: "cache-as-primary-store-without-persistence"
severity: "error"
select:
  node:
    kind: "cache"
when:
  all:
    - prop: "usedAsPrimaryStore"
      equals: true
    - prop: "persistence"
      equals: false
message: "Cache '{{node.id}}' is the primary store for its data but has persistence disabled."
```

Human page: https://localhost:3000/catalogue/rules/cache-as-primary-store-without-persistence
