Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LRUCache ¶
type LRUCache[K comparable, V any] struct { // contains filtered or unexported fields }
LRUCache is a bounded, serve-stale read-through cache backed by hashicorp/golang-lru/v2. Entries are never evicted by time: past refreshAfter they are still returned (flagged stale) so the read path never blocks on the backend, and the engine refreshes them in the background. LRU capacity is the only eviction. It is safe for concurrent use.
func NewLRUCache ¶
func NewLRUCache[K comparable, V any](maxEntries int, ttl time.Duration, t timeutil.Time) (*LRUCache[K, V], error)
NewLRUCache builds an LRU cache holding up to maxEntries values.
func (*LRUCache[K, V]) Get ¶
Get returns the cached value, whether it was found, and whether it is stale. A stale value is still returned so the caller can choose how to refresh it.
func (*LRUCache[K, V]) Invalidate ¶
func (c *LRUCache[K, V]) Invalidate(key K)
Invalidate removes key from the cache if present.
type NilCache ¶
type NilCache[K comparable, V any] struct{}
NilCache is a pass-through cache: every Get is a miss and Save is a no-op. Paired with the engine's single-flight coalescing it yields "always fetch, still deduplicate" behaviour for direct-source / live tenants.
func (NilCache[K, V]) Invalidate ¶
func (NilCache[K, V]) Invalidate(K)
type UnboundedCache ¶
type UnboundedCache[K comparable, V any] struct { // contains filtered or unexported fields }
UnboundedCache stores every saved value until it is explicitly invalidated. It supports the same stale marker as LRUCache, but does not evict by size.
func NewUnboundedCache ¶
func NewUnboundedCache[K comparable, V any](ttl time.Duration, t timeutil.Time) (*UnboundedCache[K, V], error)
NewUnboundedCache builds an unbounded cache.
func (*UnboundedCache[K, V]) Get ¶
func (c *UnboundedCache[K, V]) Get(key K) (value V, found bool, stale bool)
Get returns the cached value, whether it was found, and whether it is stale. A stale value is still returned so the caller can choose how to refresh it.
func (*UnboundedCache[K, V]) Invalidate ¶
func (c *UnboundedCache[K, V]) Invalidate(key K)
Invalidate removes key from the cache if present.
func (*UnboundedCache[K, V]) Save ¶
func (c *UnboundedCache[K, V]) Save(key K, v V)
Save stores v under key. A cache ttl <= 0 means the entry never goes stale.