Documentation
¶
Index ¶
- Constants
- Variables
- type Gate
- type OpenedCacheEntry
- type Store
- type Tracker
- func (t *Tracker) FlushWhileGuarded(ctx context.Context, versionID string) error
- func (t *Tracker) Forget(versionID string)
- func (t *Tracker) Latest(versionID string) time.Time
- func (t *Tracker) RecordAccess(ctx context.Context, versionID string, durableAccess *time.Time) error
- func (t *Tracker) RecordCommit(ctx context.Context, versionID string, durableAccess *time.Time) error
- func (t *Tracker) Run(ctx context.Context, gate *Gate, logger *slog.Logger)
- func (t *Tracker) SafeForLRU() bool
Constants ¶
const ( // DefaultPersistenceInterval bounds foreground cache-access writes while // keeping the durable LRU order reasonably current across restarts. DefaultPersistenceInterval = time.Minute )
Variables ¶
var ErrLRUAccessUncertain = errors.New("cache access is not reliable enough for LRU eviction")
ErrLRUAccessUncertain means an access timestamp could not be retained or persisted. LRU eviction must remain paused for the rest of the process.
Functions ¶
This section is empty.
Types ¶
type Gate ¶
type Gate struct {
// contains filtered or unexported fields
}
Gate serializes cache opens and commits with physical deletion for the same object version. Idle entries are removed as soon as their last user exits.
func (*Gate) GuardDeletion ¶
GuardDeletion waits for open bodies and serializes final checks and physical deletion for one version.
func (*Gate) Open ¶
func (g *Gate) Open( versionID string, open func() (io.ReadCloser, *cache.ObjectInfo, error), ) (*OpenedCacheEntry, error)
Open protects a successful cache open until the returned body is closed.
type OpenedCacheEntry ¶
type OpenedCacheEntry struct {
Body io.ReadCloser
Info *cache.ObjectInfo
}
OpenedCacheEntry keeps a cache entry protected from deletion until Body is closed.
type Store ¶
type Store interface {
RecordVersionCacheAccess(context.Context, string, time.Time) error
RecordVersionCacheCommit(context.Context, string, time.Time) error
}
Store persists foreground cache access and cache commit metadata.
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker coalesces durable access-time writes and retains the latest exact in-process access used by LRU finalization.
func NewTracker ¶
NewTracker creates a bounded foreground cache-access tracker.
func (*Tracker) FlushWhileGuarded ¶
FlushWhileGuarded persists one version's latest access. The caller must hold the version's cache gate.
func (*Tracker) Forget ¶
Forget removes tracking state after the cache entry is deleted or its version is permanently removed.
func (*Tracker) RecordAccess ¶
func (t *Tracker) RecordAccess( ctx context.Context, versionID string, durableAccess *time.Time, ) error
RecordAccess records one successful foreground cache open.
func (*Tracker) RecordCommit ¶
func (t *Tracker) RecordCommit( ctx context.Context, versionID string, durableAccess *time.Time, ) error
RecordCommit records a successful local cache commit and forces the presence and access metadata write.
func (*Tracker) SafeForLRU ¶
SafeForLRU reports whether all access timestamps that could affect LRU deletion are still represented in memory or durable storage.