feat: add source cache with stale-while-revalidate

This commit is contained in:
2026-07-05 23:08:26 +02:00
parent a9bb16d8b5
commit a0d11e3a7b
3 changed files with 312 additions and 0 deletions

View File

@@ -5,6 +5,17 @@ import (
"mal/internal/db"
)
type playbackSourceRefreshKey struct{}
func WithPlaybackSourceRefresh(ctx context.Context) context.Context {
return context.WithValue(ctx, playbackSourceRefreshKey{}, true)
}
func PlaybackSourceRefreshRequested(ctx context.Context) bool {
refresh, _ := ctx.Value(playbackSourceRefreshKey{}).(bool)
return refresh
}
type PlaybackService interface {
BuildWatchData(ctx context.Context, animeID int, titleCandidates []string, episode string, mode string, userID string) (WatchPageData, error)
SaveProgress(ctx context.Context, userID string, animeID int64, episode int, timeSeconds float64) error