@@ -3,26 +3,26 @@ package dataloader
33import "context"
44
55// The Cache interface. If a custom cache is provided, it must implement this interface.
6- type Cache interface {
7- Get (context.Context , Key ) (Thunk , bool )
8- Set (context.Context , Key , Thunk )
9- Delete (context.Context , Key ) bool
6+ type Cache [ K comparable , V any ] interface {
7+ Get (context.Context , K ) (Thunk [ V ] , bool )
8+ Set (context.Context , K , Thunk [ V ] )
9+ Delete (context.Context , K ) bool
1010 Clear ()
1111}
1212
1313// NoCache implements Cache interface where all methods are noops.
1414// This is useful for when you don't want to cache items but still
1515// want to use a data loader
16- type NoCache struct {}
16+ type NoCache [ K comparable , V any ] struct {}
1717
1818// Get is a NOOP
19- func (c * NoCache ) Get (context.Context , Key ) (Thunk , bool ) { return nil , false }
19+ func (c * NoCache [ K , V ] ) Get (context.Context , K ) (Thunk [ V ] , bool ) { return nil , false }
2020
2121// Set is a NOOP
22- func (c * NoCache ) Set (context.Context , Key , Thunk ) { return }
22+ func (c * NoCache [ K , V ] ) Set (context.Context , K , Thunk [ V ] ) { return }
2323
2424// Delete is a NOOP
25- func (c * NoCache ) Delete (context.Context , Key ) bool { return false }
25+ func (c * NoCache [ K , V ] ) Delete (context.Context , K ) bool { return false }
2626
2727// Clear is a NOOP
28- func (c * NoCache ) Clear () { return }
28+ func (c * NoCache [ K , V ] ) Clear () { return }
0 commit comments