types

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const EmptyCacheExpiration = 5 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseCache

type BaseCache struct {
	// contains filtered or unexported fields
}

func (*BaseCache) Disabled

func (c *BaseCache) Disabled() bool

func (*BaseCache) Get

func (c *BaseCache) Get(k key.Key) (interface{}, error)

func (*BaseCache) GetBool

func (c *BaseCache) GetBool(k key.Key) (bool, error)

func (*BaseCache) GetString

func (c *BaseCache) GetString(k key.Key) (string, error)

! if retrieve fail, will return ("", err) for expire time

func (*BaseCache) GetTime

func (c *BaseCache) GetTime(k key.Key) (time.Time, error)

type Cache

type Cache interface {
	Get(k key.Key) (interface{}, error)

	GetString(k key.Key) (string, error)
	GetBool(k key.Key) (bool, error)
	GetTime(k key.Key) (time.Time, error)

	Disabled() bool
}

func NewBaseCache

func NewBaseCache(disabled bool, retrieveFunc RetrieveFunc, backend backend.Backend) Cache

type EmptyCache

type EmptyCache struct {
	// contains filtered or unexported fields
}

TODO: 内存上可以优化, error相同的话使用同一个对象

type RetrieveFunc

type RetrieveFunc func(k key.Key) (interface{}, error)

Jump to

Keyboard shortcuts

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