cache

package
v1.10.35 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2021 License: MIT Imports: 20 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

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