feat: add query result caching #26

Open
opened 2026-02-21 01:03:11 +00:00 by Clotho · 0 comments
Member

Summary

Frequently executed identical queries hit the database every time. Caching safe, deterministic queries would reduce database load and improve response times.

Features

  • Cache SELECT query results with configurable TTL
  • Cache key based on query + bindings hash (not workspace-specific for identical queries, OR workspace-specific for data isolation)
  • Cache invalidation API
  • Cache hit/miss metrics
  • Bypass cache header support (X-MCP-Cache: no-cache)
  • Respect mcp.cache.ttl and mcp.cache.enabled config

Security Considerations

  • Cache must be workspace-scoped to prevent cross-tenant data leakage
  • Cache keys must include workspace ID
  • Sensitive queries (e.g. containing password) must be excluded from cache

Files

  • src/Mcp/Services/QueryCacheService.php (new)
  • Update src/Mcp/Services/QueryExecutionService.php

Notes

Also noted in TODO.md under Medium Priority. Estimated effort: 3-4 hours.

## Summary Frequently executed identical queries hit the database every time. Caching safe, deterministic queries would reduce database load and improve response times. ## Features - Cache SELECT query results with configurable TTL - Cache key based on query + bindings hash (not workspace-specific for identical queries, OR workspace-specific for data isolation) - Cache invalidation API - Cache hit/miss metrics - Bypass cache header support (`X-MCP-Cache: no-cache`) - Respect `mcp.cache.ttl` and `mcp.cache.enabled` config ## Security Considerations - Cache must be workspace-scoped to prevent cross-tenant data leakage - Cache keys must include workspace ID - Sensitive queries (e.g. containing `password`) must be excluded from cache ## Files - `src/Mcp/Services/QueryCacheService.php` (new) - Update `src/Mcp/Services/QueryExecutionService.php` ## Notes Also noted in TODO.md under Medium Priority. Estimated effort: 3-4 hours.
Clotho added the
discovery
label 2026-02-21 01:03:11 +00:00
Snider added the
clotho
label 2026-02-21 01:23:16 +00:00
Charon added the
agent-ready
label 2026-02-21 01:30:11 +00:00
Sign in to join this conversation.
No description provided.