blobcache

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStoreNotConfigured is returned when a cache operation requires a blob store.
	ErrStoreNotConfigured = errors.New("blob store is not configured")
	// ErrEntryNotFound is returned when a cache entry is missing.
	ErrEntryNotFound = errors.New("cache entry not found")
)

Functions

This section is empty.

Types

type Cache

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

Cache provides cache-oriented operations over a blob store while leaving higher-level domain serialization and refresh policy to consumers.

func New

func New(store plugin.BlobStore, namespace string, ttl time.Duration) *Cache

New constructs a cache view over a blob store.

func NewWithPolicy

func NewWithPolicy(store plugin.BlobStore, namespace string, policy Policy) *Cache

NewWithPolicy constructs a cache view with an explicit cache policy.

func (*Cache) CleanExpired

func (c *Cache) CleanExpired(ctx context.Context) error

CleanExpired removes all expired cache entries according to the configured policy.

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, key string) error

Delete removes one cache entry.

func (*Cache) DeleteNamespace

func (c *Cache) DeleteNamespace(ctx context.Context) error

DeleteNamespace clears the entire cache namespace.

func (*Cache) Dir

func (c *Cache) Dir() string

Dir returns the resolved blob store root directory when exposed by the backend.

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string) (data []byte, meta plugin.BlobMeta, ok bool, err error)

Get reads one cache entry.

func (*Cache) List

func (c *Cache) List(ctx context.Context) ([]Object, error)

List returns cache objects with policy-derived timing info.

func (*Cache) Put

func (c *Cache) Put(ctx context.Context, key string, value []byte, opts PutOptions) (plugin.BlobMeta, error)

Put stores one cache entry.

func (*Cache) TTL

func (c *Cache) TTL() time.Duration

TTL returns the cache time-to-live duration.

type Clock

type Clock interface {
	Now() time.Time
}

Clock provides time for cache policy calculations.

type Object

type Object struct {
	Key       string
	Meta      plugin.BlobMeta
	Age       time.Duration
	ExpiresIn time.Duration
}

Object describes one cached blob object together with TTL-derived timing.

type Policy

type Policy struct {
	TTL   time.Duration
	Clock Clock
}

Policy defines cache timing behavior over blob metadata.

type PutOptions

type PutOptions struct {
	ContentType string
	ExpiresAt   *time.Time
	Metadata    map[string]string
}

PutOptions controls how a cache entry is persisted.

Jump to

Keyboard shortcuts

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