MATIH Platform is in active MVP development. Documentation reflects current implementation status.
9. Query Engine & SQL
Cache Endpoints

Cache Endpoints

The cache management endpoints control the multi-level query cache, including statistics, invalidation, warming, semantic cache, adaptive policies, and analytics. Served by CacheController at /v1/cache.


Endpoints

MethodEndpointDescription
GET/v1/cache/statsGet cache statistics
GET/v1/cache/configGet cache configuration (Admin)
POST/v1/cache/invalidate/query/:queryHashInvalidate specific query
POST/v1/cache/invalidate/dependency/:depInvalidate by dependency
POST/v1/cache/invalidate/tenantInvalidate entire tenant cache (Admin)
POST/v1/cache/invalidate/schema-changeHandle schema change
POST/v1/cache/warmTrigger cache warming (Admin)
POST/v1/cache/warm/queryWarm specific query
GET/v1/cache/warming/statusGet warming status
GET/v1/cache/analytics/dashboardCache analytics dashboard
GET/v1/cache/analytics/efficiency-reportEfficiency report
GET/v1/cache/analytics/query/:queryHashAnalyze query performance
GET/v1/cache/analytics/timeseries/:metricTime-series metrics
GET/v1/cache/analytics/heatmapAccess heatmap
GET/v1/cache/semantic/statsSemantic cache statistics
GET/v1/cache/semantic/templatesPopular query templates
POST/v1/cache/semantic/normalizeNormalize SQL query
GET/v1/cache/policy/statsAdaptive policy statistics
GET/v1/cache/policy/recommendationsOptimization recommendations
POST/v1/cache/policy/freshnessConfigure table freshness (Admin)

Cache Architecture

The cache uses a two-level architecture:

LevelBackendTTLPurpose
L1In-memory (Caffeine)ShortHot query results, near-zero latency
L2RedisLongShared cache across query engine replicas

Invalidation

By query hash: Invalidates a specific cached query result.

By dependency: Invalidates all cached results that depend on a specific table or data source. Used when underlying data changes.

By schema change: Accepts a set of affected tables and invalidates all dependent cache entries.

{
  "affectedTables": ["orders", "customers"]
}

Cache Warming

Proactively populates the cache with results for frequently executed queries.

POST /v1/cache/warm

Returns 202 Accepted if warming starts, or 200 with "in_progress" if warming is already running.


Semantic Cache

The semantic cache normalizes SQL queries to identify structurally identical queries with different literal values. This increases cache hit rates for parameterized queries.

POST /v1/cache/semantic/normalize
{
  "query": "SELECT * FROM orders WHERE customer_id = 'C-001' AND date > '2026-01-01'"
}

Returns the normalized query and template hash.