✨ feat(server): cache /api/v1/greet responses + admin cache flush endpoint #29
Reference in New Issue
Block a user
Delete Branch "feat/greet-cache-admin-flush"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Extends the cache service (ADR-0022, PR #23) to two new use cases:
/api/v1/greet/{name}and/api/v1/greet?name=Xnow cache responses per name (60s TTL) withX-Cache: HIT/MISSheaderPOST /api/admin/cache/flushendpoint (admin-authenticated viaX-Admin-Passwordheader) returns flushed item countCompanion to PR #22 (rate limit) and PR #23 (cache service).
Spec
GET /api/v1/greet?name=X (existing, now cached)
X-Cache: HITif served from cache,MISSif computedgreet:v1:<name>GET /api/v1/greet/{name} (existing, now cached)
Same caching as above.
POST /api/admin/cache/flush (new)
X-Admin-Password: master admin password (req){"flushed": true, "items_flushed": N, "timestamp": "..."}{"error": "cache_disabled"}if cacheService is nilImplementation note
Replaces the previous
greetHandler.RegisterRoutes(r)call inregisterApiV1Routeswith explicit route handlers (handleGreetQuery, handleGreetPath) that add the cache layer. The greet service logic itself is unchanged.Test plan
go build ./pkg/server/...PASSgo test ./pkg/server/...PASS (existing tests, no regression)curl -i http://localhost:8080/api/v1/greet/Alicethencurl -i http://localhost:8080/api/v1/greet/Alice— second should showX-Cache: HITTest coverage deferred to BDD (existing greet scenarios exercise these handlers; cache hit/miss is incidental).
Out of scope
Migration context
ARCODANGE Phase 1 - autonomous run via Mistral Vibe with ICM workspace at
~/Work/Vibe/workspaces/greet-cache-and-admin/. Cost €2.32 stages 01-02. Trainer finalized commit/PR after Mistral's test scaffold did not compile.🤖 Co-Authored-By: Mistral Vibe + Claude Opus 4.7