Documentation
¶
Index ¶
- func SecondsToNextRescan(lastRescan time.Time, interval time.Duration, now time.Time) time.Duration
- type BuildGateObj
- type EntryObj
- type Obj
- func (obj *Obj) Clear()
- func (obj *Obj) Get(key string) (EntryObj, bool)
- func (obj *Obj) GetOrBuild(ctx context.Context, key string, ttl time.Duration, ...) (EntryObj, bool, error)
- func (obj *Obj) RegisterMetrics(meterObj metric.Meter) error
- func (obj *Obj) Set(key string, value EntryObj, ttl time.Duration)
- func (obj *Obj) Stats() StatsObj
- type StatsObj
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SecondsToNextRescan ¶
SecondsToNextRescan returns time left until the next rescan. It is the shared source for metadata TTL and server `Cache-Control: max-age`; 0 means unknown, invalid, or already expired.
Types ¶
type BuildGateObj ¶ added in v0.4.0
type BuildGateObj struct {
// contains filtered or unexported fields
}
BuildGateObj limits detached builds shared by the byte-cache and the obj-cache.
func NewBuildGate ¶ added in v0.4.0
func NewBuildGate(maxParallel uint) *BuildGateObj
func (*BuildGateObj) Acquire ¶ added in v0.4.0
func (obj *BuildGateObj) Acquire(ctx context.Context) error
func (*BuildGateObj) Release ¶ added in v0.4.0
func (obj *BuildGateObj) Release()
type EntryObj ¶
EntryObj is a cached value: payload bytes plus the ETag validator for server-side 304 handling.
type Obj ¶
type Obj struct {
// contains filtered or unexported fields
}
Obj is the cache: shards, global atomic byte budget, singleflight, and metric counters.
func New ¶
func New(cacheCfgObj stconf.CacheObj, gateArr ...*BuildGateObj) *Obj
New builds a cache with the byte budget from cache.metadata_max_size, validated in config.
func (*Obj) Clear ¶
func (obj *Obj) Clear()
Clear removes all cache entries for lifecycle or restart invalidation.
func (*Obj) GetOrBuild ¶
func (obj *Obj) GetOrBuild(ctx context.Context, key string, ttl time.Duration, buildFn func(context.Context) (EntryObj, error)) (EntryObj, bool, error)
GetOrBuild does lookup, builds exactly once through singleflight on miss, stores the result, and returns it to all waiters. Build errors are not cached. hit=true only means a fast-path cache hit.
func (*Obj) RegisterMetrics ¶
RegisterMetrics registers the cache snapshot through a single observable callback.