cache

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Host Port build Addr
	Host string
	// Port 端口
	Port string
	// Password 密码
	Password string `json:"password"`
	// DB,默认为0
	DB int `json:"db"`
	// PoolSize 最大连接池限制 默认每个CPU10个连接
	PoolSize int `json:"poolSize"`
	// MaxRetries 网络相关的错误最大重试次数 默认8次
	MaxRetries int `json:"maxRetries"`
	// MinIdleConns 最小空闲连接数
	MinIdleConns int `json:"minIdleConns"`
	// DialTimeout 拨超时时间
	DialTimeout time.Duration `json:"dialTimeout"`
	// ReadTimeout 读超时 默认3s
	ReadTimeout time.Duration `json:"readTimeout"`
	// WriteTimeout 读超时 默认3s
	WriteTimeout time.Duration `json:"writeTimeout"`
	// IdleTimeout 连接最大空闲时间,默认60s, 超过该时间,连接会被主动关闭
	IdleTimeout time.Duration `json:"idleTimeout"`
	// Debug开关
	Debug bool `json:"debug"`
}

type Redis

type Redis struct {
	*redis.Client
}

func NewRedis

func NewRedis(cf *Config) (*Redis, error)

func (*Redis) GetRedisLock

func (client *Redis) GetRedisLock(ctx context.Context, key string, expireTime int64, values ...interface{}) (interface{}, bool)

GetRedisLock redis 加锁

func (*Redis) ReleaseRedisLock

func (client *Redis) ReleaseRedisLock(ctx context.Context, key string, value interface{}) bool

ReleaseRedisLock redis 释放锁

Jump to

Keyboard shortcuts

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