cachex

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Client redis.UniversalClient

Functions

func Decr

func Decr(key string) error

Decr 指定key的值-1

func Del

func Del(keys ...string) error

Del 删除key

func Do

func Do(args ...any) *redis.Cmd

执行命令 返回结果 s, err := cmd.Text() flag, err := cmd.Bool() num, err := cmd.Int() num, err := cmd.Int64() num, err := cmd.Uint64() num, err := cmd.Float32() num, err := cmd.Float64() ss, err := cmd.StringSlice() ns, err := cmd.Int64Slice() ns, err := cmd.Uint64Slice() fs, err := cmd.Float32Slice() fs, err := cmd.Float64Slice() bs, err := cmd.BoolSlice()

func FlushDB

func FlushDB() error

清空缓存

func Get

func Get(key string) (string, error)

Get ...

func HGet

func HGet(key, field string) *redis.StringCmd

列表哈希取出

func HMGet

func HMGet(key string, fields ...string) []any

列表哈希批量取出

func HMSet

func HMSet(key string, values ...any) error

列表哈希批量插入

func HSet

func HSet(key string, values ...any) error

列表哈希插入

func Incr

func Incr(key string) error

Incr 指定key的值+1

func InitCache

func InitCache(cfg Config) error

InitCache 初始化缓存

func LPop

func LPop(key string) *redis.StringCmd

列表左边取出

func LPust

func LPust(channel string, values ...any) error

列表的头部(左边),尾部(右边) 列表左边插入

func LRange

func LRange(key string, start, stop int64) error

列表从左边开始取出start至stop位置的数据

func MGet

func MGet(keys ...string) ([]any, error)

批量设置取数据 示例:values, err := MGet(key1, key2) for i, _ := range values { fmt.Println(values[i]) }

func MSet

func MSet(values ...any) error

批量设置,没有过期时间

func Publish

func Publish(channel string, msg string) error

发布 示例Publish("mychannel1", "payload").Err()

func RPop

func RPop(key string) error

列表右边取出

func RPust

func RPust(channel string, values ...any) error

列表右边插入

func SAdd

func SAdd(key string, members ...any) error

列表无序集合插入

func SIsMember

func SIsMember(key string, member any) (bool, error)

列表无序集合,检查元素是否存在

func SMembers

func SMembers(key string) []string

列表无序集合,返回所有元素

func Set

func Set(key, val string, expiration time.Duration) error

Set ...

func Subscribe

func Subscribe(channel string, subscribe func(msg *redis.Message, err error))

订阅

Types

type Config

type Config struct {
	Addrs            []string `mapstructure:"addrs"`
	Username         string   `mapstructure:"username"`
	Password         string   `mapstructure:"password"`
	SentinelUsername string   `mapstructure:"sentinel-username"`
	SentinelPassword string   `mapstructure:"sentinel-password"`
	DB               int      `mapstructure:"db"`
	MasterName       string   `mapstructure:"master-name"`
	PoolFIFO         bool     `mapstructure:"pool-fifo"`
	PoolSize         int      `mapstructure:"pool-size"`
	MinIdleConns     int      `mapstructure:"min-idle-conns"`
	MaxIdleConns     int      `mapstructure:"max-idle-conns"`
	DialTimeout      int64    `mapstructure:"dial-timeout"`
	ReadTimeout      int64    `mapstructure:"read-timeout"`
	WriteTimeout     int64    `mapstructure:"write-timeout"`
	PoolTimeout      int64    `mapstructure:"pool-timeout"`
	MaxRetries       int      `mapstructure:"max-retries"`
	MinRetryBackoff  int64    `mapstructure:"min-retry-backoff"`
	MaxRetryBackoff  int64    `mapstructure:"max-retry-backoff"`
}

Jump to

Keyboard shortcuts

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