Documentation
¶
Overview ¶
Package cache is a small in-process TTL cache for read-only tool results. Concurrent misses for one key share a single upstream load (singleflight), and entries older than half their TTL are served stale while one background refresh runs.
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 keys are "<profile>/<kind>/<id>".
func (*Cache) Get ¶
func (c *Cache) Get(ctx context.Context, key string, ttl time.Duration, load func(context.Context) (any, error)) (any, error)
Get returns the cached value for key or loads it.
func (*Cache) Invalidate ¶
Invalidate drops every key with the given prefix.