Commit Graph

5 Commits

Author SHA1 Message Date
c58fbb50b1 feat: implement observability and metrics (Task 22)
- Add metrics package tracking cache hit-rate, API quota, circuit breaker trips, search time
- Integrate metrics with cache layer, yandex client, and API handlers
- Add /metrics HTTP endpoint for Prometheus-compatible metrics exposure
- Write tests for metrics functionality across cache, yandex, and API handlers
- Update test files to support new metrics infrastructure
2026-08-17 15:27:44 +03:00
5842667fff feat: Implement user preferences (saved cities, search history) with Redis storage and API handlers 2026-08-17 14:30:54 +03:00
6ae491ef1c feat: Implement basic caching layer with cache-aside pattern for /search results
- Implement cache-aside pattern via SearchCacheService in RouteSearch handler
- Add TTL policies: 3 hours near-term, 7 days far-term
- Write TestCacheAsideSearch and variants for TTL verification
- Extend CacheAside to fully implement Cache interface (Get, Set, Exists, Delete, Increment, Decrement)
2026-08-16 14:53:33 +03:00
e063d26d4c fix: code correctness, security, and simplicity improvements 2026-08-13 21:23:15 +03:00
571d11d376 feat: implement cache-aside layer with Redis cache interface, cache keys, TTL policies, and tests
- Created cache/store.go with Cache interface, redisClient wrapper, cacheStore, TTL constants (CityTTL 30d, SearchNearTermTTL 3h, SearchFarTermTTL 7d)
- Implemented cache keys: cities:{code}, stations:{id}, search:{from}:{to}:{date}
- Implemented cache-aside pattern via CacheAside struct with GetOrSetFuncPattern, GetCity, GetStation, GetSearch
- Added TTL-aware search result caching with near-term (3h) and far-term (7d) policies
- Wrote 6 unit tests: CacheGetSet, CacheKeyString, CacheAsideGetOrSet, CacheAsideGetCity, CacheAsideGetSearch, CacheInvalidate
- All tests pass with Redis integration
2026-08-13 19:55:02 +03:00