internal

package
v0.0.0-...-214dd1a Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package internal 依赖的内部实现

Index

Constants

View Source
const (
	OK               = "ok"
	ErrTypeNotMatch  = "redis return type not match"           // redis返回数据类型不匹配
	ErrWLockConflict = "write lock conflict"                   // 写锁冲突
	ErrHadWLock      = "had write lock, lock read lock failed" // 已经有写锁,加读锁失败
	ErrLockNotExist  = "lock not exist"                        // 锁不存在
	ErrLockFailed    = "lock failed"                           // 加锁失败
	ErrCasConflict   = "cas conflict"                          // cas 冲突
)

分布式锁相关常量定义

Variables

View Source
var (
	//go:embed script/lock_or_refresh.lua
	LockOrRefreshScript string
	//go:embed script/refresh.lua
	RefreshScript string
	//go:embed script/unlock.lua
	UnLockScript string
	//go:embed script/rlock.lua
	RLockScript string
	//go:embed script/runlock.lua
	RUnlockScript string
	//go:embed script/wlock.lua
	WLockScript string
	//go:embed script/wunlock.lua
	WUnlockScript string
	//go:embed script/cas.lua
	CasScript string
)

lua脚本变量定义,直接将lua脚本加载进二进制

Functions

func ExecLuaScript

func ExecLuaScript(ctx context.Context, client *redis.Client, Key, script string, Vals ...any) error

ExecLuaScript 执行lua脚本

Types

type CasVal

type CasVal struct {
	Val     any
	Version int64
}

type LockInfo

type LockInfo struct {
	Key   string
	Val   string
	Lease time.Duration
}

LockInfo 锁结构信息

Jump to

Keyboard shortcuts

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