Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func GetOrSet ¶
func GetOrSet[T any](cache Cache, ctx context.Context, key string, ttl time.Duration, fn func() (*T, error)) (*T, error)
GetOrSet is a helper function that allow you get existing entry from the cache or set it if it does not exist yet the function must return a pointer of the expected type and an error
Types ¶
type Cache ¶
type Cache interface { patterns.Connectable Get(ctx context.Context, key string, entry any) error Set(ctx context.Context, key string, entry any, ttl time.Duration) error Exist(ctx context.Context, key string) bool Del(ctx context.Context, key string) error Expire(ctx context.Context, key string, at time.Time) error }
Click to show internal directories.
Click to hide internal directories.