Documentation
¶
Overview ¶
Package cache defines a generic read-result cache with per-table invalidation. Writes (create/update/delete) call Invalidate(table) to drop entries for that table precisely, rather than relying on blind TTL expiry (Oracle result-cache semantics). TTLCache uses sync.Map and lazy expiry; weak-pointer soft caching is a future refinement.
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(ctx context.Context, k Key) (T, bool) Set(ctx context.Context, k Key, v T) error Invalidate(entity string) error }
Cache is a generic read cache with per-table invalidation.
type NoopCache ¶
type NoopCache[T any] struct{}
NoopCache is a Cache that stores nothing.
func (NoopCache[T]) Invalidate ¶
Invalidate is a no-op.
type TTLCache ¶
type TTLCache[T any] struct { // contains filtered or unexported fields }
TTLCache stores values with a TTL, evaluated lazily on Get. Set removes all expired entries before evicting an arbitrary live entry to stay under the configured cap.
func NewTTLCache ¶
NewTTLCache returns a TTLCache. maxSize <= 0 uses a safe default capacity.
func (*TTLCache[T]) Invalidate ¶
Invalidate removes all entries whose Key.Entity matches.