From 18a6adad16aaa6f7a202f4fe06b42d4e52ab6385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Leszko?= Date: Fri, 26 Jul 2024 15:05:34 +0200 Subject: [PATCH] Cache also errors when caching lapi.GetStreamByPlaybackID() (#1346) Related to Victor's comment. --- mapic/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mapic/utils.go b/mapic/utils.go index cb7c92c8e..1be294149 100644 --- a/mapic/utils.go +++ b/mapic/utils.go @@ -32,7 +32,7 @@ type entry struct { func (a *ApiClientCached) GetStreamByPlaybackID(playbackId string) (*api.Stream, error) { a.mu.RLock() e, ok := a.streamCache[playbackId] - if ok && e.stream != nil && e.updateAt.Add(a.ttl).After(time.Now()) { + if ok && e.updateAt.Add(a.ttl).After(time.Now()) { // Use cached value a.mu.RUnlock() return e.stream, e.err @@ -44,7 +44,7 @@ func (a *ApiClientCached) GetStreamByPlaybackID(playbackId string) (*api.Stream, defer a.mu.Unlock() // Check again in case another goroutine has updated the cache in the meantime e, ok = a.streamCache[playbackId] - if ok && e.stream != nil && e.updateAt.Add(a.ttl).After(time.Now()) { + if ok && e.updateAt.Add(a.ttl).After(time.Now()) { return e.stream, e.err } // No value in the cache, fetch from Livepeer API and store the result in a cache