fix: address code review findings

This commit is contained in:
2026-08-18 14:25:34 +03:00
parent 48650d96cf
commit 0d603ad15f
6 changed files with 56 additions and 24 deletions

View File

@@ -29,8 +29,12 @@ func NewSearchCacheService(cacheStore cache.Cache, yclient *yandex.Client, m *me
// SearchWithCache performs a route search with caching support.
// It uses the cache-aside pattern: try cache first, then Yandex API, then write back to cache.
func (s *SearchCacheService) SearchWithCache(ctx context.Context, from, to, date string, opts SearchOptions) (*yandex.Response, error) {
// Generate cache key
searchKey := cache.GetSearchKey(from, to, date)
// Generate cache key including far-term flag to distinguish near-term vs far-term searches
farTermFlag := "near"
if opts.FarTerm {
farTermFlag = "far"
}
searchKey := cache.GetSearchKeyWithFarTerm(from, to, date, farTermFlag)
// Try to get from cache first
fetchFunc := func() ([]byte, error) {