Documentation
¶
Index ¶
- Constants
- Variables
- func GetDecode[T any](ctx context.Context, cache Getter, key string) (T, error)
- func SetEncode[T any](ctx context.Context, cache Setter, key string, value T, ttl time.Duration) error
- type Cache
- type Engine
- type Getter
- type NoopCache
- func (NoopCache) AllowRateLimit(_ context.Context, _ string, _ time.Duration, _ int, _ time.Duration) (bool, error)
- func (NoopCache) Get(_ context.Context, _ string) (string, bool, error)
- func (NoopCache) Invalidate(_ context.Context, _ string) error
- func (NoopCache) Ping(ctx context.Context) error
- func (NoopCache) Set(_ context.Context, _, _ string, _ time.Duration) error
- func (NoopCache) SetIfAbsent(_ context.Context, _, _ string, _ time.Duration) (bool, error)
- func (NoopCache) Shutdown(_ context.Context) error
- type Setter
Constants ¶
View Source
const NoCache = time.Duration(0)
NoCache is passed as TTL to indicate that no expiration should be set.
Variables ¶
View Source
var ErrSetIfAbsentUnsupported = errors.New("cache does not support atomic set-if-absent")
Functions ¶
Types ¶
type Cache ¶
type Cache interface {
Getter
Setter
SetIfAbsent(ctx context.Context, key string, value string, ttl time.Duration) (stored bool, err error)
// AllowRateLimit consumes one token, refilling one token per interval up to burst.
AllowRateLimit(
ctx context.Context, key string, interval time.Duration, burst int, ttl time.Duration,
) (allowed bool, err error)
Invalidate(ctx context.Context, key string) error
}
type NoopCache ¶
type NoopCache struct{}
NoopCache is a no-op implementation of Cache intended for tests.
func (NoopCache) AllowRateLimit ¶
func (NoopCache) SetIfAbsent ¶
Click to show internal directories.
Click to hide internal directories.