redis

package
v0.0.0-...-d853fe5 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ConfigDSN config dsn description
	ConfigDSN = "./conf/app.yaml"

	// RedisSection redis
	RedisSection = "redis"
)

Functions

func DLock

func DLock(c context.Context, lockKey, requestId string) (releaseLock func(), err error)

DLock 获取分布式锁,成功需要释放锁

func ReleaseDistributedLock

func ReleaseDistributedLock(c context.Context, lockKey, requestId string) (bool, error)

ReleaseDistributedLock 释放锁,通过比较requestId,用于确保只释放自己的锁,使用lua脚本保证操作的原子型

func TryGetDistributedLock

func TryGetDistributedLock(c context.Context, lockKey, requestId string, isNegative bool) bool

TryGetDistributedLock 分布式锁获取 requestId 用于标识请求客户端,可以是随机字符串,需确保唯一

Types

type DefaultHook

type DefaultHook struct{}

1: log 2: trace todo 3: metrics todo

func (DefaultHook) AfterProcess

func (DefaultHook) AfterProcess(ctx entity.Context, cmd redis.Cmder) error

AfterProcess 后回调

func (DefaultHook) AfterProcessPipeline

func (DefaultHook) AfterProcessPipeline(ctx entity.Context, cmds []redis.Cmder) error

AfterProcessPipeline 后pipeline

func (DefaultHook) BeforeProcess

func (DefaultHook) BeforeProcess(ctx entity.Context, cmd redis.Cmder) (entity.Context, error)

BeforeProcess 前回调

func (DefaultHook) BeforeProcessPipeline

func (DefaultHook) BeforeProcessPipeline(ctx entity.Context, cmds []redis.Cmder) (entity.Context, error)

BeforeProcessPipeline 前pipeline

Jump to

Keyboard shortcuts

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