Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[T any] interface { // Get returns the value for the given key. // If the key is not found, found will be false. Get(ctx context.Context, key string) (value T, found bool) // Sets the value for the given key. Set(ctx context.Context, key string, value T) // Removes the key from the cache. Remove(ctx context.Context, key string) }
func NewNoopCache ¶
type Config ¶
type Config[T any] struct { // How long the data is considered fresh // Subsequent requests in this time will try to use the cache Fresh time.Duration // Subsequent requests that are not fresh but within the stale time will return cached data but also trigger // fetching from the origin server Stale time.Duration // A handler that will be called to refetch data from the origin when necessary RefreshFromOrigin func(ctx context.Context, identifier string) (T, error) Logger *zap.Logger }
Click to show internal directories.
Click to hide internal directories.