cache

package
v0.0.0-...-3fc60fe Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultKey the collection name of redis for cache adapter.
	DefaultKey = "commonRedis"
)
View Source
var RetryMaxTimeInterval int64 = 30

Lock请求锁的最大时间间隔(毫秒)

View Source
var RetryMinTimeInterval int64 = 5

当一次Lock失败之后,会随机在RetryMinTimeInterval和RetryMaxTimeInterval之间 取一个随机值作为下次请求锁的时间间隔 Lock请求锁的最小时间间隔(毫秒)

Functions

This section is empty.

Types

type Cache

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

Cache is Redis cache adapter.

func NewCache

func NewCache(conn string) (*Cache, error)

NewRedisCache create new redis cache with default collection name.

func (*Cache) Brpop

func (rc *Cache) Brpop(key string, callback func([]byte))

func (*Cache) DelMuti

func (rc *Cache) DelMuti(keys ...string) error

DelMuti delete cache in redis.

func (*Cache) Delete

func (rc *Cache) Delete(key string) error

Delete delete cache in redis.

func (*Cache) Do

func (rc *Cache) Do(commandName string, args ...interface{}) (reply interface{}, err error)

actually do the redis cmds

func (*Cache) Get

func (rc *Cache) Get(key string) interface{}

Get cache from redis.

func (*Cache) GetRedisTTL

func (rc *Cache) GetRedisTTL(key string) time.Duration

func (*Cache) Incrby

func (rc *Cache) Incrby(key string, num int) (interface{}, error)

Decr decrease counter in redis.

func (*Cache) IsExist

func (rc *Cache) IsExist(key string) bool

IsExist check cache's existence in redis.

func (*Cache) LPush

func (rc *Cache) LPush(key string, val interface{}) error

Put put cache to redis.

func (*Cache) LRem

func (rc *Cache) LRem(key string, count int, val interface{}) error

Put put cache to redis.

func (*Cache) Lock

func (rc *Cache) Lock(key string, timeout time.Duration) bool

func (*Cache) Put

func (rc *Cache) Put(key string, val interface{}, timeout time.Duration) error

Put put cache to redis.

func (*Cache) RedisBytes

func (rc *Cache) RedisBytes(key string) (data []byte, err error)

func (*Cache) RedisInt

func (rc *Cache) RedisInt(key string) (data int, err error)

func (*Cache) RedisString

func (rc *Cache) RedisString(key string) (data string, err error)

func (*Cache) SetNX

func (rc *Cache) SetNX(key string, val interface{}, timeout time.Duration) bool

func (*Cache) StartAndGC

func (rc *Cache) StartAndGC(config string) error

StartAndGC start redis cache adapter. config is like {"key":"collection key","conn":"connection info","dbNum":"0"} the cache item in redis are stored forever, so no gc operation.

Jump to

Keyboard shortcuts

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