cache

package
v3.14.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2017 License: Apache-2.0, Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachePool

type CachePool struct {
	Cache *cache.Cache
}

Callback function used to load data from data source if the cache is not existing Sets the cache pool and loading function

func (CachePool) Get

func (cachePool CachePool) Get(key string, cacheWorker CacheWorker) (interface{}, error)

Gets data by key(or load it by provided function)

type CacheWorker

type CacheWorker interface {
	// Get data of object which is missed in cache
	LoadSourceData() (interface{}, error)
	// Put loaded data of object into cache
	// 2nd parameter is the search
	SetCache(*cache.Cache, interface{})
}

Defines the behavior of access on cache pool 1. The getter of key in cache pool 2. The loading of source data if object is not in cache 3. The setting of data to cache

Jump to

Keyboard shortcuts

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