Cache is an interface for a cache that can be used to store and retrieve values.
| 28 | // Cache is an interface for a cache |
| 29 | // that can be used to store and retrieve values. |
| 30 | type Cache[T any] interface { |
| 31 | Set(ctx context.Context, key string, value T) error |
| 32 | SetWithTTL(ctx context.Context, key string, value T, ttl time.Duration) error |
| 33 | Delete(ctx context.Context, key string) error |
| 34 | Get(ctx context.Context, key string) (T, error) |
| 35 | GetAll(ctx context.Context, selectFunc Matcher) (map[string]T, error) |
| 36 | UpdateTTL(ctx context.Context, key string, ttl time.Duration) error |
| 37 | SetOnEvicted(f func(key string, value T)) |
| 38 | Close() error |
| 39 | } |
| 40 | |
| 41 | // Matcher is a function that returns true if the key matches. |
| 42 | type Matcher func(key string) bool |
no outgoing calls
no test coverage detected