cache

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCacheTimeout = 24 * time.Hour
	CurrentVersion      = 1
	InfoPrefix          = "cache_info"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Get KVS of this cache. Note: Kvs may not actually store data.
	// It's depends on the cache policy. Caller must avoid rely on this Kvs as
	// a regular storage.
	Kvs() kv_kvs.Kvs
}

func NoCache

func NoCache() Cache

type Controller

type Controller interface {
	// Startup cache controller. Broken or expired caches will be evicted on startup.
	Startup() error

	// Shutdown caches
	Shutdown()

	// Get or create new cache
	Cache(namespace, name string) (cache Cache)
}

func New

func New(basePath string, logger esl.Logger) Controller

type Info

type Info struct {
	Version   int       `json:"version"`
	Namespace string    `json:"namespace"`
	Name      string    `json:"name"`
	Expire    time.Time `json:"expire"`
	Last      time.Time `json:"last"`
}

func (Info) DatabaseName

func (z Info) DatabaseName() string

type Lifecycle

type Lifecycle interface {
	Cache

	// Open cache
	Open() error

	// Evict this cache if required (e.g. timeout)
	EvictIfRequired()

	// Flush and close this cache
	Close()
}

Jump to

Keyboard shortcuts

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