cache

package module
v0.0.0-...-c46b51c Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRedisClient = "default-redis-client"
	MinIdleConns       = 50
	PoolSize           = 20
	MaxRetries         = 3
)

Variables

View Source
var CacheStdLogger stdLogger

Functions

func GetBigBucket

func GetBigBucket(ID int64) int64

高49位作捅,低15为作offset

func GetBigKey

func GetBigKey(key string, ID int64) string

func GetBigOffset

func GetBigOffset(ID int64) int64

0x7FFF的二进制为111111111111111 与ID做与运算结果保留了ID的低15位

func GetBucket

func GetBucket(userID int64) int64

对于redis bitmap范围内的数据,使用高16位作捅,低16位作offset

func GetKey

func GetKey(key string, ID int64) string

func GetOffset

func GetOffset(ID int64) int64

func InitClusterRedis

func InitClusterRedis(clientName string, opt *redis.ClusterOptions, trace *trace.Cache) error

func InitRedis

func InitRedis(clientName string, opt *redis.Options, trace *trace.Cache) error

Types

type Cache

type Cache interface {
	Set(key string, value interface{}, ttl time.Duration) error
	Get(key string) interface{}
	GetStr(key string) (value string, err error)
	TTL(key string) (time.Duration, error)
	Expire(key string, ttl time.Duration) (bool, error)
	ExpireAt(key string, ttl time.Time) (bool, error)
	Delete(key string) error
	Exists(keys ...string) (bool, error)
	IsExist(key string) bool
	Incr(key string) (int64, error)
	SetBit(key string, offset int64, val int) (value int64, err error)
	GetBit(key string, offset int64) (value int64, err error)
	SetBigBit(key string, offset int64, val int) (value int64, err error)
	GetBigBit(key string, offset int64) (value int64, err error)
	SetBitNOBucket(key string, offset int64, val int) (value int64, err error)
	GetBitNOBucket(key string, offset int64) (value int64, err error)
	BitCountNOBucket(key string, start, end int64) (value int64, err error)
	Close() error
	Version() string
}

type Redis

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

func GetRedisClient

func GetRedisClient(name string) *Redis

func GetRedisClusterClient

func GetRedisClusterClient(name string) *Redis

func (*Redis) BitCountNOBucket

func (r *Redis) BitCountNOBucket(key string, start, end int64) (value int64, err error)

func (*Redis) BitOPNOBucket

func (r *Redis) BitOPNOBucket(op, destKey string, keys ...string) (value int64, err error)

func (*Redis) Close

func (r *Redis) Close() error

Close close redis client

func (*Redis) Delete

func (r *Redis) Delete(key string) error

func (*Redis) Exists

func (r *Redis) Exists(keys ...string) (bool, error)

func (*Redis) Expire

func (r *Redis) Expire(key string, ttl time.Duration) (bool, error)

Expire expire some key

func (*Redis) ExpireAt

func (r *Redis) ExpireAt(key string, ttl time.Time) (bool, error)

ExpireAt expire some key at some time

func (*Redis) Get

func (r *Redis) Get(key string) interface{}

Get get some key from redis

func (*Redis) GetBigBit

func (r *Redis) GetBigBit(key string, offset int64) (value int64, err error)

func (*Redis) GetBit

func (r *Redis) GetBit(key string, offset int64) (value int64, err error)

func (*Redis) GetBitNOBucket

func (r *Redis) GetBitNOBucket(key string, offset int64) (value int64, err error)

func (*Redis) GetStr

func (r *Redis) GetStr(key string) (value string, err error)

func (*Redis) Incr

func (r *Redis) Incr(key string) (value int64, err error)

func (*Redis) IsExist

func (r *Redis) IsExist(key string) bool

func (*Redis) Set

func (r *Redis) Set(key string, value interface{}, ttl time.Duration) error

Set set some <key,value> into redis

func (*Redis) SetBigBit

func (r *Redis) SetBigBit(key string, offset int64, val int) (value int64, err error)

func (*Redis) SetBit

func (r *Redis) SetBit(key string, offset int64, val int) (value int64, err error)

func (*Redis) SetBitNOBucket

func (r *Redis) SetBitNOBucket(key string, offset int64, val int) (value int64, err error)

func (*Redis) TTL

func (r *Redis) TTL(key string) (time.Duration, error)

TTL get some key from redis

func (*Redis) Version

func (r *Redis) Version() string

Version redis server version

Jump to

Keyboard shortcuts

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