cache

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cacheable

type Cacheable struct {
	Expires  lib.JSONTime `json:"_expires"`
	Contents interface{}  `json":contents"`
}

Cacheable defines metadata for objects which can be cached to files as JSON

type State

type State int

State defines the return of the Store and Get calls

const (
	// CacheFound means the key was found and valid
	CacheFound State = iota
	// CacheExpired means the key was found, but has expired. The value returned is not valid.
	CacheExpired
	// CacheNoEntry means the key was not found.
	CacheNoEntry
	// CacheNotAvailable means the cache system is not working as expected and has an internal error
	CacheNotAvailable
)

func Get

func Get(key string, decodeTo interface{}) State

Get gets a key from the named cache file

func Store

func Store(key string, lifetime time.Duration, data interface{}) State

Store stores the given data interface as a JSON file with a given expiration time under the given key.

Jump to

Keyboard shortcuts

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