cache

package
v1.0.29 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCleanTask added in v1.0.18

func AddCleanTask(task func() error, keys ...string)

func TotalWeights added in v1.0.18

func TotalWeights(c []NodeConf) int

Types

type Cache added in v1.0.18

type Cache interface {
	DelCache(keys ...string) error
	GetCache(key string, v interface{}) error
	SetCache(key string, v interface{}) error
	SetCacheWithExpire(key string, v interface{}, expire time.Duration) error
	Take(v interface{}, key string, query func(v interface{}) error) error
	TakeWithExpire(v interface{}, key string, query func(v interface{}, expire time.Duration) error) error
}

func NewCache added in v1.0.18

func NewCache(c ClusterConf, barrier syncx.SharedCalls, st *CacheStat, errNotFound error,
	opts ...Option) Cache

func NewCacheNode added in v1.0.18

func NewCacheNode(rds *redis.Redis, barrier syncx.SharedCalls, st *CacheStat,
	errNotFound error, opts ...Option) Cache

type CacheConf

type CacheConf = ClusterConf

type CacheStat added in v1.0.18

type CacheStat struct {

	// export the fields to let the unit tests working,
	// reside in internal package, doesn't matter.
	Total   uint64
	Hit     uint64
	Miss    uint64
	DbFails uint64
	// contains filtered or unexported fields
}

func NewCacheStat added in v1.0.18

func NewCacheStat(name string) *CacheStat

func (*CacheStat) IncrementDbFails added in v1.0.18

func (cs *CacheStat) IncrementDbFails()

func (*CacheStat) IncrementHit added in v1.0.18

func (cs *CacheStat) IncrementHit()

func (*CacheStat) IncrementMiss added in v1.0.18

func (cs *CacheStat) IncrementMiss()

func (*CacheStat) IncrementTotal added in v1.0.18

func (cs *CacheStat) IncrementTotal()

type ClusterConf added in v1.0.18

type ClusterConf []NodeConf

type NodeConf added in v1.0.18

type NodeConf struct {
	redis.RedisConf
	Weight int `json:",default=100"`
}

type Option

type Option func(o *Options)

func WithExpiry

func WithExpiry(expiry time.Duration) Option

func WithNotFoundExpiry

func WithNotFoundExpiry(expiry time.Duration) Option

type Options added in v1.0.18

type Options struct {
	Expiry         time.Duration
	NotFoundExpiry time.Duration
}

Jump to

Keyboard shortcuts

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