redis

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyBase = "general:"        //基础
	KeyLock = KeyBase + "lock:" //锁
)

Variables

View Source
var (
	Default *redis.Client
	Ctx     = context.Background()
	Nil     = redis.Nil
)

Functions

func Add

func Add(name string, option Option)

func AddMap

func AddMap(name string, setting map[string]interface{})

func AddMapBatch

func AddMapBatch(batch map[string]interface{})

func Cluster

func Cluster(name string) *redis.ClusterClient

Cluster 使用集群

func Lock

func Lock(name string, expire time.Duration) bool

Lock 加锁,单位秒

func Unlock

func Unlock(name string)

Unlock 解锁

func Use

func Use(name string) *redis.Client

Use 使用

Types

type MaxMin

type MaxMin struct {
	CacheKey string //缓存键名
	Name     string //名称,CacheKey+Name=唯一标识
}

func (*MaxMin) Delete

func (m *MaxMin) Delete()

Delete 删除

func (*MaxMin) Get

func (m *MaxMin) Get() int

Get 获取

func (*MaxMin) SetMax

func (m *MaxMin) SetMax(newId int) error

SetMax 设置最大值,大于才会覆盖

func (*MaxMin) SetMin

func (m *MaxMin) SetMin(newId int) error

SetMin 设置最小值,小于才会覆盖

type Option

type Option struct {
	Address  []string `json:"address"`   //地址,字符串数组
	Password string   `json:"password"`  //密码,默认空
	DB       int      `json:"db"`        //db
	PoolSize int      `json:"pool_size"` //连接池最大数量,默认100
}

Jump to

Keyboard shortcuts

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