0.2.78
This commit is contained in:
@@ -331,14 +331,25 @@ func (s *Server) radarrMovieCatalogue(ctx context.Context) ([]radarr.Movie, erro
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if body, marshalErr := json.Marshal(movies); marshalErr == nil {
|
||||
if cacheErr := s.cache.Set(ctx, radarrMovieCacheKey, body, s.cfg.RadarrTTL); cacheErr != nil {
|
||||
s.loggerFor(ctx).Warn("radarr movie cache write failed", "error", cacheErr)
|
||||
}
|
||||
}
|
||||
s.cacheRadarrMovies(ctx, movies)
|
||||
return movies, nil
|
||||
}
|
||||
|
||||
// cacheRadarrMovies stores the household's shared copy of Radarr's catalogue.
|
||||
//
|
||||
// Split out because the scheduled refresh writes it too: that task reads Radarr directly
|
||||
// — a refresh satisfied by the cache it exists to replace would do nothing — and would
|
||||
// otherwise need its own copy of the key, the TTL and the failure handling.
|
||||
func (s *Server) cacheRadarrMovies(ctx context.Context, movies []radarr.Movie) {
|
||||
body, err := json.Marshal(movies)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if cacheErr := s.cache.Set(ctx, radarrMovieCacheKey, body, s.cfg.RadarrTTL); cacheErr != nil {
|
||||
s.loggerFor(ctx).Warn("radarr movie cache write failed", "error", cacheErr)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) cachedRadarrMovies(ctx context.Context) []radarr.Movie {
|
||||
raw, err := s.cache.Get(ctx, radarrMovieCacheKey)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user