cache

package
v1.1.3-0...-a28cbea Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCleanTask

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

func TotalWeights

func TotalWeights(c []NodeConf) int

Types

type Cache

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

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

func NewCacheNode

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

type CacheConf

type CacheConf = ClusterConf

type CacheStat

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

func NewCacheStat(name string) *CacheStat

func (*CacheStat) IncrementDbFails

func (cs *CacheStat) IncrementDbFails()

func (*CacheStat) IncrementHit

func (cs *CacheStat) IncrementHit()

func (*CacheStat) IncrementMiss

func (cs *CacheStat) IncrementMiss()

func (*CacheStat) IncrementTotal

func (cs *CacheStat) IncrementTotal()

type ClusterConf

type ClusterConf []NodeConf

type NodeConf

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

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