cache

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cache coordinates callers of a borrowed xdatly byte cache. It owns no backend or cached values; its metadata is local to one owner.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coordinator

type Coordinator struct {
	// contains filtered or unexported fields
}

Coordinator shares in-flight fetches and fences writes across local invalidations. Backend operations and value validation never hold mu.

func New

func New(clock func() time.Time) *Coordinator

func (*Coordinator) Count

func (c *Coordinator) Count(ctx context.Context, backend xcache.Cache) (int, error)

Count reconciles locally tracked entries against backend eviction.

func (*Coordinator) Invalidate

func (c *Coordinator) Invalidate(ctx context.Context, backend xcache.Cache, partition string, all bool) (int, error)

Invalidate changes the key generation before deleting old physical keys. Slow backend deletes cannot block unrelated requests or resurrect old data.

func (*Coordinator) Resolve

func (c *Coordinator) Resolve(ctx context.Context, backend xcache.Cache, key, partition string, valid func([]byte) (time.Time, bool), fetch func(context.Context) (Outcome, error)) ([]byte, bool, error)

Resolve returns a live backend hit or shares one fetch for this generation. valid checks the caller's absolute-expiry envelope outside the mutex.

type Outcome

type Outcome struct {
	Value   []byte
	Expires time.Time
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL