0.2.81
This commit is contained in:
@@ -260,7 +260,16 @@ func (s *Server) handleAdminHeroPolicy(w http.ResponseWriter, r *http.Request) {
|
||||
writeError(w, http.StatusInternalServerError, "could not save hero policy")
|
||||
return
|
||||
}
|
||||
s.invalidateAllHomeCaches(r.Context())
|
||||
// No cache sweep. The hero revision is part of the home and section-hero cache keys,
|
||||
// so the entries built under the policy just replaced are already unreachable and age
|
||||
// out on their own TTL; this only drops *this* instance's copy of the document, which
|
||||
// is what makes the operator's own next read the answer they just saved rather than
|
||||
// the one they replaced.
|
||||
//
|
||||
// It used to call InvalidateUser for every account in the house, which threw away
|
||||
// every cached item lookup, image and row the household had in order to change four
|
||||
// cards — so a hero edit made the next launcher on every set rebuild from Emby.
|
||||
s.heroPolicy.invalidate()
|
||||
writeJSON(w, http.StatusOK, map[string]any{"saved": true})
|
||||
}
|
||||
|
||||
@@ -277,16 +286,3 @@ func uniqueHeroIDs(ids []string) []string {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (s *Server) invalidateAllHomeCaches(ctx context.Context) {
|
||||
users, err := s.store.KnownUsers(ctx)
|
||||
if err != nil {
|
||||
s.loggerFor(ctx).Warn("hero cache invalidation could not list users", "error", err)
|
||||
return
|
||||
}
|
||||
for _, user := range users {
|
||||
if err := s.cache.InvalidateUser(ctx, user.ID); err != nil {
|
||||
s.loggerFor(ctx).Warn("hero cache invalidation failed", "user", user.ID, "error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user