From bad4ef14c88ae36c666b90f4078dca6dad5567f4 Mon Sep 17 00:00:00 2001 From: motoki317 Date: Thu, 9 Nov 2023 23:26:08 +0900 Subject: [PATCH] Add doc of behavior when replaceFunc returns an error, resolves #5 --- cache.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cache.go b/cache.go index 7f64777..79e1413 100644 --- a/cache.go +++ b/cache.go @@ -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.