Pre-flight checklist
Problem to solve
High-traffic discovery endpoints (/crops, /resources, /geoids, /parameters) execute the same DB queries on every request. While materialized views make individual queries fast, there's no application-layer cache preventing redundant round-trips to Cloud SQL for identical inputs within a request window.
Proposed solution or API
Use a simple TTL cache (e.g. cachetools.TTLCache or functools.lru_cache with a time wrapper) on the service layer functions. TTL should be keyed to the ETL refresh interval. No Redis required — an in-process cache is sufficient given Cloud Run's single-process-per-instance model.
Alternatively, evaluate Redis via Cloud Memorystore if cross-instance consistency becomes a requirement when min-instances > 1.
Alternatives considered
HTTP caching headers (see related issue) — complementary, not a substitute. Headers help clients; in-memory cache helps the server avoid DB round-trips.
Additional context
Ref: #135 (caching sub-task).
Pre-flight checklist
Problem to solve
High-traffic discovery endpoints (
/crops,/resources,/geoids,/parameters) execute the same DB queries on every request. While materialized views make individual queries fast, there's no application-layer cache preventing redundant round-trips to Cloud SQL for identical inputs within a request window.Proposed solution or API
Use a simple TTL cache (e.g.
cachetools.TTLCacheorfunctools.lru_cachewith a time wrapper) on the service layer functions. TTL should be keyed to the ETL refresh interval. No Redis required — an in-process cache is sufficient given Cloud Run's single-process-per-instance model.Alternatively, evaluate Redis via Cloud Memorystore if cross-instance consistency becomes a requirement when
min-instances > 1.Alternatives considered
HTTP caching headers (see related issue) — complementary, not a substitute. Headers help clients; in-memory cache helps the server avoid DB round-trips.
Additional context
Ref: #135 (caching sub-task).