cacheeviction

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StageLRU                       = "lru"
	StageAfterUpload               = "after_upload"
	StageReconcileBucketDurability = "reconcile_bucket_durability"
)

Variables

View Source
var ErrAccessChanged = errors.New("cache access snapshot changed")

ErrAccessChanged means an LRU candidate was accessed after it was planned.

View Source
var ErrDurabilityThreshold = errors.New("minimum durable copies not met")

ErrDurabilityThreshold means the current Bucket policy does not authorize deletion.

View Source
var ErrNoLongerEligible = errors.New("cache entry is no longer eligible")

ErrNoLongerEligible means a planned cache entry no longer matches the deletion contract.

Functions

func DeleteAuthorized

func DeleteAuthorized(task *model.Task) (bool, error)

DeleteAuthorized reports whether the task has crossed the durable deletion authorization boundary.

func NewAfterUploadTask

func NewAfterUploadTask(objectID int64, versionID string, maxRetries int, scheduledAt time.Time) *model.Task

NewAfterUploadTask builds the stable task for post-upload eviction.

func NewBucketDurabilityTask

func NewBucketDurabilityTask(bucketID int64, maxRetries int, scheduledAt time.Time) *model.Task

NewBucketDurabilityTask builds the singleton reconciliation task for one bucket.

func NewLRUTask

func NewLRUTask(candidate Candidate, maxRetries int, scheduledAt time.Time) *model.Task

NewLRUTask builds the stable task for one candidate access snapshot.

func NormalizeAccessTime

func NormalizeAccessTime(value time.Time) time.Time

NormalizeAccessTime matches the timestamp precision supported by both PostgreSQL and SQLite persistence paths.

func WithDeleteAuthorization

func WithDeleteAuthorization(payload map[string]any) map[string]any

WithDeleteAuthorization copies payload before recording an authorization.

Types

type AuthorizedDeletion

type AuthorizedDeletion struct {
	Version    model.ObjectVersion
	BucketName string
}

AuthorizedDeletion is the persisted decision needed to remove one cache entry outside the database transaction that approved it.

type Candidate

type Candidate struct {
	ObjectID   int64     `bun:"object_id"`
	VersionID  string    `bun:"version_id"`
	Size       int64     `bun:"size"`
	AccessedAt time.Time `bun:"cache_accessed_at"`
}

Candidate is the persisted snapshot needed to plan one LRU eviction.

type LRUTaskPayload

type LRUTaskPayload struct {
	AccessedAt time.Time
}

LRUTaskPayload is the typed boundary for an LRU task's persisted payload.

func ParseLRUTaskPayload

func ParseLRUTaskPayload(task *model.Task) (LRUTaskPayload, error)

ParseLRUTaskPayload validates and decodes the persisted LRU access snapshot.

Jump to

Keyboard shortcuts

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