cache

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2019 License: BSD-3-Clause Imports: 6 Imported by: 0

README

cache

Documentation

Index

Constants

View Source
const (
	OK status = iota
	EXPIRED
	MISS
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Expiration time.Duration // 过期时间
	// contains filtered or unexported fields
}

func New

func New(source Source, sourceTimeout int64, retries int, retryInterval int, expiration int, maxLen, maxMgetLen int) (*Cache, error)

func (*Cache) Close

func (c *Cache) Close()

func (*Cache) Get

func (c *Cache) Get(key string, mts ...MGetTraceWrapper) ([]byte, Info)

func (*Cache) MGet

func (c *Cache) MGet(keys []string, mts ...MGetTraceWrapper) (map[string][]byte, Info)

func (*Cache) Set

func (c *Cache) Set(key string, value []byte) (Info, error)

type CallMap

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

func (*CallMap) DoMGet

func (self *CallMap) DoMGet(kvsResult *CallRes, fn func(...string) (map[string][]byte, error), keys ...string)

key_1 *call1 key_2 *call1 key_3 *call1 key_4 *call2 key_5 *call2 key_6 *call3 key_7 *call3 1. when get kvs: key_1 key_2 key_5 key_11 new(call) = *call4 start *call4 , wait for *call1 *call2, *call4 2. when get kvs: key_11 wait for *call4

type CallRes

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

func NewCallRes

func NewCallRes(keys ...string) *CallRes

func (*CallRes) GetCopy

func (crs *CallRes) GetCopy() map[string]*resItem

func (*CallRes) Set

func (crs *CallRes) Set(key string, done bool, v []byte, err error) bool

type Get added in v0.3.0

type Get func(key string) ([]byte, error)

type GetTraceWrapper added in v0.3.0

type GetTraceWrapper func(Get) Get

type Info

type Info struct {
	Cached           int
	Total            int
	Empty            int
	StatusOk         int
	StatusExpired    int
	StatusMiss       int
	StatusElse       int
	StatusUnCached   int
	MergeFromCallMap int
	TriggerExpired   int
	TriggerPushFront int
	Action           string
	Key              string
}

type Item

type Item struct {
	Key       string
	Value     []byte
	Status    status
	Retries   int
	CreatedAt time.Time
	UpdatedAt time.Time
}

type MGet added in v0.3.0

type MGet func(keys ...string) (map[string][]byte, error)

type MGetTraceWrapper added in v0.3.0

type MGetTraceWrapper func(MGet) MGet

type Source

type Source interface {
	Get(key string) ([]byte, error)
	MGet(keys ...string) (map[string][]byte, error)
	Set(key string, value []byte) error
	Close()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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