Skip to content

Commit

Permalink
Add doc of behavior when replaceFunc returns an error, resolves #5
Browse files Browse the repository at this point in the history
  • Loading branch information
motoki317 committed Nov 9, 2023
1 parent 89a9b42 commit bad4ef1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"time"
)

// replaceFunc is automatically called when value is not present or expired.
// The cache makes sure that replaceFunc is always called once for the same key at the same time.
// When replaceFunc returns an error, value will not be cached.
type replaceFunc[K comparable, V any] func(ctx context.Context, key K) (V, error)

// NewMust is similar to New, but panics on error.
Expand Down

0 comments on commit bad4ef1

Please sign in to comment.