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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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