cache

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Add(task.Task)
	Get(id string) TaskJob
}

type DurationStats

type DurationStats struct {
	Min time.Duration
	Max time.Duration
	// contains filtered or unexported fields
}

func (*DurationStats) Add

func (s *DurationStats) Add(d time.Duration)

func (*DurationStats) Average

func (s *DurationStats) Average() time.Duration

func (*DurationStats) String

func (s *DurationStats) String() string

type Memory

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

func NewMemory

func NewMemory(ttl_minutes int) *Memory

func (*Memory) Add

func (c *Memory) Add(t task.Task)

Add a task to the cache the task must have an id to be added.

func (*Memory) Get

func (c *Memory) Get(id string) TaskJob

Get the TaskJob info with the given id. If the id isn't found a _ is returned

func (*Memory) Recap

func (c *Memory) Recap() map[string]*Stats

func (*Memory) Recycle

func (c *Memory) Recycle() Stat

Recycle iterates through the cache clearing all tasks that have been completed within the cache window it returns a list of tasks that have not been completed but have expired

type Stat

type Stat struct {
	Count       int
	Removed     int
	ProcessTime time.Duration
	Unfinished  []task.Task
}

type Stats

type Stats struct {
	CompletedCount int
	CompletedTimes []time.Time

	ErrorCount int
	ErrorTimes []time.Time

	ExecTimes *DurationStats
}

func (*Stats) Add

func (stats *Stats) Add(tsk task.Task)

func (*Stats) MarshalJSON

func (s *Stats) MarshalJSON() ([]byte, error)

func (Stats) String

func (s Stats) String() string

type TaskJob

type TaskJob struct {
	LastUpdate time.Time // time since the last event with id
	Completed  bool

	Events []task.Task
	// contains filtered or unexported fields
}

todo: name to describe info about completed tasks that are within the cache

Jump to

Keyboard shortcuts

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