cache

package
v0.1.11 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheConfig

type CacheConfig struct {
	ScheduleTTL time.Duration // default 300ms
	JobTTL      time.Duration // default 5s
	MaxJobCache int           // default 1000
}

CacheConfig configures cache TTLs and sizes.

func DefaultCacheConfig

func DefaultCacheConfig() CacheConfig

DefaultCacheConfig returns sensible defaults.

type ScheduleCache

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

ScheduleCache wraps ListDueSchedules and GetJob with short-TTL in-memory caching. Safe for concurrent use. Designed for single-scheduler-per-process scenarios.

func NewScheduleCache

func NewScheduleCache(store ScheduleStore, cfg CacheConfig) *ScheduleCache

NewScheduleCache creates a cache wrapping the given store.

func (*ScheduleCache) GetJob

func (c *ScheduleCache) GetJob(ctx context.Context, jobID string) (*types.Job, uint64, error)

GetJob returns a cached job or fetches from the underlying store.

func (*ScheduleCache) InvalidateJob

func (c *ScheduleCache) InvalidateJob(jobID string)

InvalidateJob removes a specific job from the job cache.

func (*ScheduleCache) InvalidateSchedules

func (c *ScheduleCache) InvalidateSchedules()

InvalidateSchedules clears the due-schedule cache.

func (*ScheduleCache) ListDueSchedules

func (c *ScheduleCache) ListDueSchedules(ctx context.Context, cutoff time.Time) ([]*types.ScheduleEntry, error)

ListDueSchedules returns cached results if TTL has not expired, otherwise fetches from the underlying store.

type ScheduleStore

type ScheduleStore interface {
	ListDueSchedules(ctx context.Context, cutoff time.Time) ([]*types.ScheduleEntry, error)
	GetJob(ctx context.Context, jobID string) (*types.Job, uint64, error)
}

ScheduleStore is the interface the cache wraps (satisfied by store.RedisStore).

Jump to

Keyboard shortcuts

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