Documentation
¶
Overview ¶
Package cachetest owns behavior shared by Foundry's cache adapter acceptance.
Index ¶
- func Run(t *testing.T, setup func(*testing.T) (Backend, func(string) cache.EntryKey))
- func RunBasicEntries(t *testing.T, ...)
- func RunContendedExpiry(t *testing.T, ...)
- func RunEntries(t *testing.T, setup func(*testing.T) EntryFixture)
- func RunNamespace(t *testing.T, setup func(*testing.T) NamespaceFixture)
- func RunPersistent(t *testing.T, setup func(*testing.T) PersistentFixture)
- func RunTagged(t *testing.T, setup func(*testing.T) TaggedFixture)
- type AtomicExpiryBackend
- type Backend
- type BasicEntryBackend
- type EntryAdapter
- type EntryFixture
- type NamespaceFixture
- type PersistentBackend
- type PersistentFixture
- type TaggedBackend
- type TaggedFixture
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunBasicEntries ¶
func RunBasicEntries(t *testing.T, setup func(*testing.T) (BasicEntryBackend, func(string) cache.EntryKey))
RunBasicEntries covers optional inspection/expiry independently of tags.
func RunContendedExpiry ¶
func RunContendedExpiry(t *testing.T, prepare func(*testing.T) (AtomicExpiryBackend, *testkit.Clock, cache.EntryKey))
RunContendedExpiry holds the actual adapter lock while a competing metadata operation starts. The application clock advances without wall-clock sleeps. Reads take no mutation lock: Exists completes while the lock is held and evaluates liveness at its own observation time.
func RunEntries ¶
func RunEntries(t *testing.T, setup func(*testing.T) EntryFixture)
func RunNamespace ¶
func RunNamespace(t *testing.T, setup func(*testing.T) NamespaceFixture)
RunNamespace checks the same automatic typed-store contract in memory and Redis.
func RunPersistent ¶
func RunPersistent(t *testing.T, setup func(*testing.T) PersistentFixture)
RunPersistent checks the file and PostgreSQL capacity, unusable-entry and namespace flush contracts.
Types ¶
type AtomicExpiryBackend ¶
type AtomicExpiryBackend interface {
BasicEntryBackend
Access(context.Context, cache.EntryKey, cacheatomic.Mode, cacheatomic.Change) error
}
type BasicEntryBackend ¶
type BasicEntryBackend interface {
Backend
cache.EntryBackend
}
type EntryAdapter ¶
type EntryAdapter interface {
TaggedBackend
cache.EntryBackend
cache.TaggedEntryBackend
cache.BatchBackend
cache.TaggedBatchBackend
}
type EntryFixture ¶
type NamespaceFixture ¶
type NamespaceFixture struct {
Backend TaggedBackend
Namespace keyspace.Namespace
Track func(cache.EntryKey)
}
NamespaceFixture owns exact test addresses; no backend enumeration is needed.
type PersistentBackend ¶
type PersistentBackend interface {
BasicEntryBackend
cache.FlushBackend
Sweep(context.Context, int) (cacheatomic.PruneResult, error)
}
PersistentBackend is a durable adapter that reclaims expiry itself and invalidates a namespace by physical removal.
type PersistentFixture ¶
type PersistentFixture struct {
Open func(t *testing.T, maxEntries, maxValueBytes int) PersistentBackend
Clock *testkit.Clock
Key func(namespace keyspace.Namespace, logical string) cache.EntryKey
}
PersistentFixture opens backends over one shared durable store. Every opened backend reads expiry from Clock; Open varies only the entry and value bounds.
type TaggedBackend ¶
type TaggedBackend interface {
Backend
cache.TaggedBackend
cache.TaggedCounterBackend
}