Documentation
¶
Overview ¶
Package cache is a small TTL cache with single-flight refresh, used for upstream list results.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache maps string keys to values with per-entry TTLs.
func (*Cache) GetOrFill ¶
func (c *Cache) GetOrFill(ctx context.Context, key string, ttl time.Duration, fill func(context.Context) (any, error)) (any, error)
GetOrFill returns the cached value for key, or runs fill (once across concurrent callers) and caches its result for ttl. ttl <= 0 bypasses the cache entirely.
func (*Cache) Invalidate ¶
Invalidate drops all entries whose key has the given prefix.
Click to show internal directories.
Click to hide internal directories.