cache

package
v0.0.0-...-a2093d6 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: LGPL-2.1 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RedisStr     actionType = iota // 字符串类型
	RedisList                      // 列表类型
	RedisHash                      // 哈希类型
	RedisSortSet                   // 排序集合类型
	RedisSet                       // 集合类型
)
View Source
const DefaultMaxLimit = 10000

Variables

View Source
var ErrTooLargeOffset = errors.New("too large offset")

ErrTooLargeOffset indicates the offset is too large in bitset.

Functions

func GetEmptyCache

func GetEmptyCache() *gocache.Cache

func GetMemoryCache

func GetMemoryCache() *gocache.Cache

func GetRedisCli

func GetRedisCli() redisc.Client

func Hash

func Hash(data []byte) uint64

Hash returns the hash value of data.

func InitMemoryCache

func InitMemoryCache(expire time.Duration, clean time.Duration)

func InitRedis

func InitRedis(ctx context.Context, config redisc.Config) (err error)

Types

type BloomFilter

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

布隆过滤器结构体

func (*BloomFilter) Add

func (f *BloomFilter) Add(data []byte) error

func (*BloomFilter) Exists

func (f *BloomFilter) Exists(data []byte) (bool, error)

type RedisConfig

type RedisConfig struct {
	Addr     string
	Password string
	DB       int // 0 default DB

}

func (RedisConfig) DSN

func (c RedisConfig) DSN() interface{}

type RedisDriver

type RedisDriver struct {
	Client *redis.Client
	// contains filtered or unexported fields
}

func NewRedisDriver

func NewRedisDriver(config *RedisConfig) (*RedisDriver, error)

NewRedisDriver driver构造函数

func (*RedisDriver) BasicGet

func (d *RedisDriver) BasicGet(key string) interface{}

基本数据类型的基本获取

func (*RedisDriver) BasicSet

func (d *RedisDriver) BasicSet(key string, value interface{}, expir time.Duration, typ actionType) (e error)

BasicSet 基本数据类型的添加元素

func (*RedisDriver) NewBitSet

func (d *RedisDriver) NewBitSet(key string, bits uint) *redisBitSet

获取bitset数据结构

func (*RedisDriver) NewBloomFilter

func (d *RedisDriver) NewBloomFilter(bits uint, key string) *BloomFilter

布隆过滤器的构造函数

func (*RedisDriver) NewLock

func (d *RedisDriver) NewLock(key string) *RedisLock

获取分布式锁实例

func (*RedisDriver) Ping

func (d *RedisDriver) Ping() bool

Ping 测试连通性

type RedisLock

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

func (*RedisLock) Acquire

func (rl *RedisLock) Acquire() (bool, error)

获取分布式锁

func (*RedisLock) Release

func (rl *RedisLock) Release() (bool, error)

释放获取到的分布式锁

func (*RedisLock) SetExpire

func (rl *RedisLock) SetExpire(seconds int)

Jump to

Keyboard shortcuts

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