cacher

package
v5.0.0-...-03972fd Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 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 Cacher

type Cacher interface {
	FetchData(
		class string,
		dependencies map[string]string,
		dst interface{},
		builder func() (interface{}, error),
		lifeTime time.Duration,
	) error

	FetchHtml(
		class string,
		dependencies map[string]string,
		builder func() (tpl Template, data interface{}, err error),
		lifeTime time.Duration,
	) (html string, err error)

	// Invalidate depended data
	Invalidate(key, val string) error
}

func New

func New(
	storage Storage,
) Cacher

type Storage

type Storage interface {
	// Lock key
	Lock(key string)
	// Unlock key
	Unlock(key string)

	// Get value by key. Returns data.ErrNoMatch, if has no key.
	Get(key string, dst interface{}) error
	// Set value with key and expire time.
	Set(key string, val interface{}, timeout time.Duration) error
	// Delete cached value by key.
	Delete(key string) error

	// Assert depended key
	Assert(key string, dependencies map[string]string) error
	// Invalidate depended data
	Invalidate(key, val string) error
}

type Template

type Template interface {
	Execute(w io.Writer, data interface{}) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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