mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-06 05:57:35 +03:00
chore(server): add more info to scrobble errors logs (#3889)
* chore(server): add more info to scrobble errors Signed-off-by: Deluan <deluan@navidrome.org> * chore(server): add more info to scrobble errors Signed-off-by: Deluan <deluan@navidrome.org> * chore(server): add more info to scrobble errors Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
46a2ec0ba1
commit
5ab345c83e
4 changed files with 22 additions and 13 deletions
9
utils/cache/simple_cache.go
vendored
9
utils/cache/simple_cache.go
vendored
|
@ -2,6 +2,7 @@ package cache
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
|
@ -74,10 +75,13 @@ func (c *simpleCache[K, V]) Get(key K) (V, error) {
|
|||
}
|
||||
|
||||
func (c *simpleCache[K, V]) GetWithLoader(key K, loader func(key K) (V, time.Duration, error)) (V, error) {
|
||||
var err error
|
||||
loaderWrapper := ttlcache.LoaderFunc[K, V](
|
||||
func(t *ttlcache.Cache[K, V], key K) *ttlcache.Item[K, V] {
|
||||
c.evictExpired()
|
||||
value, ttl, err := loader(key)
|
||||
var value V
|
||||
var ttl time.Duration
|
||||
value, ttl, err = loader(key)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -87,6 +91,9 @@ func (c *simpleCache[K, V]) GetWithLoader(key K, loader func(key K) (V, time.Dur
|
|||
item := c.data.Get(key, ttlcache.WithLoader[K, V](loaderWrapper))
|
||||
if item == nil {
|
||||
var zero V
|
||||
if err != nil {
|
||||
return zero, fmt.Errorf("cache error: loader returned %w", err)
|
||||
}
|
||||
return zero, errors.New("item not found")
|
||||
}
|
||||
return item.Value(), nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue