Skip to content

Query caching layer #30

Description

@andreahlert

Problem

Frequently executed queries (dashboard stats, navigation counts, config lookups) hit SQLite on every request. For read-heavy pages, caching would improve performance significantly.

Proposal

Syntax

page /dashboard
  query stats: select count(*) as users from user
    cache 5m
  query recent: select title from post order by created desc limit 5
    cache 1m

Behavior

  • cache DURATION stores query results in memory for the specified duration
  • Cache key: SQL string + bound parameter values
  • Invalidation: automatic on any mutation (INSERT/UPDATE/DELETE) to the referenced tables
  • Manual invalidation: not needed for v1 (automatic is good enough)

Implementation

  • In-memory cache (sync.Map or similar)
  • TTL-based expiration
  • Table-level invalidation (parse SQL to detect referenced tables)

Non-goals (for now)

  • Redis or external cache
  • Per-user cache isolation
  • Cache warming on startup

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions