cache

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMultiRedisCache

func NewMultiRedisCache(addr, pass string) (caches map[int]ICache, err error)

NewMultiRedisCache 创建多个redis缓存

Types

type ICache

type ICache interface {
	Close()
	Get(ctx context.Context, key string) (string, error)
	GetInt(ctx context.Context, key string) (int, error)
	Set(ctx context.Context, key string, value interface{}, expire int) error
	Del(ctx context.Context, key string) error
	Incr(ctx context.Context, key string) (int64, error)
	Exists(ctx context.Context, key string) (bool, error)
	Expire(ctx context.Context, key string, expire int) error
	SAdd(ctx context.Context, key string, members ...interface{}) error
	SMembers(ctx context.Context, key string) ([]string, error)
	SRem(ctx context.Context, key string, members ...interface{}) error
	SCard(ctx context.Context, key string) (int64, error)
	SIsMember(ctx context.Context, key string, member interface{}) (bool, error)
	HSet(ctx context.Context, key string, kv ...interface{}) error
	HGet(ctx context.Context, key, field string) (string, error)
	HMSet(ctx context.Context, key string, kvs ...interface{}) error
	HMGet(ctx context.Context, key string, fields ...string) ([]interface{}, error)
	HGetAll(ctx context.Context, key string) (map[string]string, error)
	HExists(ctx context.Context, key, filed string) (bool, error)
	HDel(ctx context.Context, key string, fields ...string) error
	ZAdd(ctx context.Context, key string, list map[string]float64) error
	ZRangeByScore(ctx context.Context, key string, min, max string, off, lim int64) ([]string, error)
	ZRevRangeByScore(ctx context.Context, key string, min, max string, off, lim int64) ([]string, error)
	ZRem(ctx context.Context, key string, members ...interface{}) error
	Keys(ctx context.Context, pattern string) ([]string, error)
}

ICache 缓存接口

func NewRedisCache

func NewRedisCache(cmd redis.Cmdable) ICache

NewRedisCache 创建redis缓存

func NewRedisCacheWithParams

func NewRedisCacheWithParams(addr, pass string, db int) ICache

NewRedisCacheWithParams 根据参数创建redis缓存

Jump to

Keyboard shortcuts

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