@@ -36,20 +36,20 @@ type Cache[K comparable, V any] struct {
3636 callGroup singleflight.Group [K , V ]
3737}
3838
39- func (c * Cache [K , V ]) Get (ctx context.Context , key K , fn singleflight. DoFunc [ V ] ) (V , error ) {
39+ func (c * Cache [K , V ]) Get (ctx context.Context , key K , fn func () ( V , error ) ) (V , error ) {
4040 return c .get (ctx , key , false , fn )
4141}
4242
43- func (c * Cache [K , V ]) GetFresh (ctx context.Context , key K , fn singleflight. DoFunc [ V ] ) (V , error ) {
43+ func (c * Cache [K , V ]) GetFresh (ctx context.Context , key K , fn func () ( V , error ) ) (V , error ) {
4444 return c .get (ctx , key , true , fn )
4545}
4646
47- func (c * Cache [K , V ]) Set (ctx context.Context , key K , fn singleflight. DoFunc [ V ] ) (V , bool , error ) {
47+ func (c * Cache [K , V ]) Set (ctx context.Context , key K , fn func () ( V , error ) ) (V , bool , error ) {
4848 v , err , shared := c .callGroup .Do (key , c .set (key , fn ))
4949 return v , shared , err
5050}
5151
52- func (c * Cache [K , V ]) get (ctx context.Context , key K , freshOnly bool , fn singleflight. DoFunc [ V ] ) (V , error ) {
52+ func (c * Cache [K , V ]) get (ctx context.Context , key K , freshOnly bool , fn func () ( V , error ) ) (V , error ) {
5353 c .mu .RLock ()
5454 val , ok := c .values .Get (key )
5555 c .mu .RUnlock ()
@@ -73,8 +73,8 @@ func (c *Cache[K, V]) get(ctx context.Context, key K, freshOnly bool, fn singlef
7373 return v , err
7474}
7575
76- func (c * Cache [K , V ]) set (key K , fn singleflight. DoFunc [ V ]) singleflight. DoFunc [ V ] {
77- return singleflight. DoFunc [ V ]( func () (V , error ) {
76+ func (c * Cache [K , V ]) set (key K , fn func () ( V , error )) func () ( V , error ) {
77+ return func () (V , error ) {
7878 val , err := fn ()
7979 if err != nil {
8080 return val , err
@@ -89,7 +89,7 @@ func (c *Cache[K, V]) set(key K, fn singleflight.DoFunc[V]) singleflight.DoFunc[
8989 c .mu .Unlock ()
9090
9191 return val , nil
92- })
92+ }
9393}
9494
9595type value [V any ] struct {
0 commit comments