Skip to content

Commit

Permalink
Cache also errors when caching lapi.GetStreamByPlaybackID()
Browse files Browse the repository at this point in the history
Related to Victor's comment.
  • Loading branch information
leszko committed Jul 26, 2024
1 parent 40126a6 commit d622ee6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mapic/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d622ee6

Please sign in to comment.