refactor: namespace cache keys to prevent collisions #50

Merged
Snider merged 1 commit from refactor/namespace-cache-keys into main 2026-02-23 06:21:34 +00:00
Member

Summary

  • Replace hardcoded 'agentic.for-agents.json' cache key in ForAgentsController with a config-driven key (mcp.cache.for_agents_key) to prevent cross-module collisions
  • Add configurable TTL via mcp.cache.for_agents_ttl config entry (default 3600 s); Cache-Control header now reflects the configured value
  • Add cacheKey() public method on the controller for testability and cache invalidation ergonomics
  • Add tests/Feature/ForAgentsControllerTest.php covering key customisation, cache storage/invalidation, TTL, and response structure

Closes #20 (CQ-003 in TODO.md)

Test plan

  • ForAgentsControllerTest – cache key uses config value
  • ForAgentsControllerTest – falls back to default key when config is null
  • ForAgentsControllerTest – data is stored under the namespaced key
  • ForAgentsControllerTestCache::forget(cacheKey()) invalidates cache
  • ForAgentsControllerTest – configured TTL reflected in Cache-Control header

🤖 Generated with Claude Code

## Summary - Replace hardcoded `'agentic.for-agents.json'` cache key in `ForAgentsController` with a config-driven key (`mcp.cache.for_agents_key`) to prevent cross-module collisions - Add configurable TTL via `mcp.cache.for_agents_ttl` config entry (default 3600 s); `Cache-Control` header now reflects the configured value - Add `cacheKey()` public method on the controller for testability and cache invalidation ergonomics - Add `tests/Feature/ForAgentsControllerTest.php` covering key customisation, cache storage/invalidation, TTL, and response structure Closes #20 (CQ-003 in TODO.md) ## Test plan - [ ] `ForAgentsControllerTest` – cache key uses config value - [ ] `ForAgentsControllerTest` – falls back to default key when config is null - [ ] `ForAgentsControllerTest` – data is stored under the namespaced key - [ ] `ForAgentsControllerTest` – `Cache::forget(cacheKey())` invalidates cache - [ ] `ForAgentsControllerTest` – configured TTL reflected in `Cache-Control` header 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Clotho added 1 commit 2026-02-23 06:19:48 +00:00
refactor: namespace cache keys to prevent collisions (closes #20)
Some checks failed
CI / PHP 8.3 (pull_request) Failing after 1m35s
CI / PHP 8.4 (pull_request) Failing after 1m31s
7fba0955e4
Replace hardcoded cache key in ForAgentsController with a config-based
key (`mcp.cache.for_agents_key`) and configurable TTL
(`mcp.cache.for_agents_ttl`). This prevents collisions with other modules
or packages that might use the same flat cache key.

- Add `cacheKey()` method on ForAgentsController, reads from config
- Add `cache` section to config.php with default key and TTL
- Dynamic Cache-Control max-age now follows the configured TTL
- Add ForAgentsControllerTest covering key customisation,
  cache storage, invalidation, TTL, and response structure

Refs: TODO.md CQ-003

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Snider merged commit 00a7e2f4ef into main 2026-02-23 06:21:34 +00:00
Snider deleted branch refactor/namespace-cache-keys 2026-02-23 06:21:34 +00:00
Sign in to join this conversation.
No description provided.