Skip to content

Commit 5a2bd95

Browse files
committed
Upgrade panic safety comments
1 parent 3b90b8a commit 5a2bd95

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cache.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (c *Cache[K, V]) LoadOrStore(key K, ttl time.Duration, value V) (old V, loa
8686
return v, loaded
8787
}
8888

89-
// MustFetch fetches a value without handling errors. It is safe to panic in f.
89+
// MustFetch fetches a value or panics if f panics.
9090
func (c *Cache[K, V]) MustFetch(key K, ttl time.Duration, f func() V) (value V) {
9191
v, _ := c.TryFetch(key, func() (V, time.Duration, error) {
9292
value := f()
@@ -96,7 +96,7 @@ func (c *Cache[K, V]) MustFetch(key K, ttl time.Duration, f func() V) (value V)
9696
}
9797

9898
// Fetch loads or stores a value for key. If a value exists, f will not be called,
99-
// otherwise f will be called to fetch the new value. It is safe to panic in f.
99+
// otherwise f will be called to fetch the new value. It panics if f panics.
100100
// Concurrent Fetches for the same key will block each other and return a single result.
101101
func (c *Cache[K, V]) Fetch(key K, ttl time.Duration, f func() (V, error)) (value V, err error) {
102102
return c.TryFetch(key, func() (V, time.Duration, error) {

0 commit comments

Comments
 (0)