reports

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 8 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 struct {
	*cache.Cache[string, *Entry]
	// contains filtered or unexported fields
}

Cache caches the different reports generated by the server

func NewCache

func NewCache(duration time.Duration) *Cache

NewCache returns a new cache that caches the reports for the specified duration

func (*Cache) Load

func (cache *Cache) Load(name string) *Entry

Load returns a cached report. If the report does not exist, or is expired, it sets up Once to generate a new report

func (*Cache) MaybeGenerate

func (cache *Cache) MaybeGenerate(name string, generate func() (*tabulator.Tabulator, error)) (report *tabulator.Tabulator, err error)

MaybeGenerate loads a report from Cache, or generates it if the report does not exist or is expired

func (*Cache) Save

func (cache *Cache) Save(name string, entry *Entry)

Save stores a generated report in the cache

func (*Cache) Stats

func (cache *Cache) Stats() (stats map[string]int)

Stats returns the stats of the cache

type Entry

type Entry struct {
	Once sync.Once
	Data *tabulator.Tabulator
}

Entry represents one report in the cache

Jump to

Keyboard shortcuts

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