Documentation
¶
Overview ¶
Package metadata is the per-replica object-metadata cache.
Responsibilities:
- bounded TTL'd cache of ObjectInfo keyed on (origin_id, bucket, key)
- separate negative-TTL handling for 404 / unsupported-blob-type entries
- per-replica HEAD singleflight so concurrent misses collapse to one Origin.Head
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 is the per-replica metadata cache.
func NewCache ¶
NewCache builds a Cache from config. The log is used at debug level for cache hit / miss / record / invalidate trace lines and at warn level for unexpected backend errors caught during result recording. Passing nil falls back to slog.Default().
func (*Cache) Invalidate ¶
Invalidate drops the entry.
func (*Cache) LookupOrFetch ¶
func (c *Cache) LookupOrFetch( ctx context.Context, originID, bucket, key string, fetch func(ctx context.Context) (origin.ObjectInfo, error), ) (origin.ObjectInfo, error)
LookupOrFetch returns the cached ObjectInfo on hit (positive or negative); on miss, runs the per-replica HEAD singleflight against fetch and caches the result with the appropriate TTL.
Singleflight tradeoff: the first caller (leader) drives fetch with its own ctx. If the leader's ctx is cancelled mid-fetch, joiners observe the leader's resulting ctx-error rather than their own (still-valid) ctx. This is the standard singleflight contract; a joiner can re-issue after seeing ctx.Err on a closed sfe.done if it wants to drive its own attempt.