Documentation
¶
Overview ¶
Package testutil provides a shared in-memory core/cache.ExternalCache fake for cache/* package tests. Importable only from packages rooted under cache/, per Go's internal-package visibility rule.
Index ¶
- type FakeExternalCache
- func (f *FakeExternalCache) Del(_ context.Context, key string) error
- func (f *FakeExternalCache) DelPrefix(_ context.Context, prefix string) error
- func (f *FakeExternalCache) Get(_ context.Context, key string, into any) (bool, error)
- func (f *FakeExternalCache) Keys() []string
- func (f *FakeExternalCache) Set(_ context.Context, key string, val any, ttl time.Duration) error
- func (f *FakeExternalCache) TTL(key string) (time.Duration, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeExternalCache ¶
type FakeExternalCache struct {
// contains filtered or unexported fields
}
FakeExternalCache is an in-memory, JSON-serializing implementation of core/cache.ExternalCache. Values are marshaled on Set and unmarshaled on Get, matching how the real Redis/Memcached backends behave — a naive map[string]any passthrough would hide (de)serialization bugs.
func NewFakeExternalCache ¶
func NewFakeExternalCache() *FakeExternalCache
NewFakeExternalCache constructs an empty FakeExternalCache.
func (*FakeExternalCache) Del ¶
func (f *FakeExternalCache) Del(_ context.Context, key string) error
func (*FakeExternalCache) DelPrefix ¶
func (f *FakeExternalCache) DelPrefix(_ context.Context, prefix string) error
func (*FakeExternalCache) Keys ¶
func (f *FakeExternalCache) Keys() []string
Keys returns a snapshot of every key currently stored, for assertions on exact key formatting.
Click to show internal directories.
Click to hide internal directories.