cache

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 5 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 {
	// contains filtered or unexported fields
}

Cache represents simple in-memory key/value store that can be persisted

func New

func New(name string, maxAge int64) (*Cache, error)

New instantiates new Cache

  • name is the name of the cache file
  • maxAge controls amount of seconds after which cache returns no entry even though an old one exists (-1 disables aging, 0 disables caching)

func (*Cache) Add

func (cache *Cache) Add(id, name string, valid bool)

Add cache entry

func (*Cache) Dump added in v1.2.0

func (cache *Cache) Dump() map[string]Value

Dump returns cache data

func (*Cache) Get

func (cache *Cache) Get(id string) (string, bool)

Get cache entry by key

func (*Cache) Write

func (cache *Cache) Write() error

Write persists cache to disk

type Value added in v1.2.0

type Value struct {
	Name      string `json:"name"`
	Valid     bool   `json:"valid"`
	UpdatedAt int64  `json:"updatedAt"` // in µs
}

Value represents value in cache

Jump to

Keyboard shortcuts

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