Merge branch 'upstream/main' into main
All checks were successful
Build and Push Container Image / build-and-push (push) Successful in 9m21s
All checks were successful
Build and Push Container Image / build-and-push (push) Successful in 9m21s
This commit is contained in:
@@ -45,9 +45,9 @@ func (h *AnimeHandler) getCachedAnimeScheduleWeek(ctx context.Context, year int,
|
||||
cacheKey := fmt.Sprintf("%d-%02d-%s", year, week, timezone)
|
||||
const ttl = 10 * time.Minute
|
||||
|
||||
h.scheduleCacheMu.Lock()
|
||||
h.Lock()
|
||||
cached, ok := h.scheduleCache[cacheKey]
|
||||
h.scheduleCacheMu.Unlock()
|
||||
h.Unlock()
|
||||
|
||||
if ok && time.Since(cached.fetchedAt) < ttl {
|
||||
return cached.value, nil
|
||||
@@ -58,9 +58,9 @@ func (h *AnimeHandler) getCachedAnimeScheduleWeek(ctx context.Context, year int,
|
||||
return animeschedule.WeekSchedule{}, err
|
||||
}
|
||||
|
||||
h.scheduleCacheMu.Lock()
|
||||
h.Lock()
|
||||
h.scheduleCache[cacheKey] = cachedWeekSchedule{fetchedAt: time.Now(), value: value}
|
||||
h.scheduleCacheMu.Unlock()
|
||||
h.Unlock()
|
||||
|
||||
return value, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user