redis

package
v0.0.0-...-b71bc5b Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 默认连接池超过 10 s 释放连接
	DefaultIdleTimeoutSeconds = 10
	// 默认最大激活连接数
	DefaultMaxActive = 100
	// 默认最大空闲连接数
	DefaultMaxIdle = 20
)

Variables

View Source
var (

	// 添加任务 lua 脚本
	//go:embed lua/add_task.lua
	AddTaskLuaScript string

	// 删除任务 lua 脚本
	//go:embed lua/delete_task.lua
	DeleteTaskLuaScript string

	// 取任务 lua 脚本
	//go:embed lua/range_tasks.lua
	RangeTasksLuaScript string
)

Functions

func RepairClient

func RepairClient(c *ClientOptions)

Types

type ClientOption

type ClientOption func(c *ClientOptions)

func WithDB

func WithDB(db int) ClientOption

func WithIdleTimeoutSeconds

func WithIdleTimeoutSeconds(idleTimeoutSeconds int) ClientOption

func WithMaxActive

func WithMaxActive(maxActive int) ClientOption

func WithMaxIdle

func WithMaxIdle(maxIdle int) ClientOption

func WithWaitMode

func WithWaitMode() ClientOption

type ClientOptions

type ClientOptions struct {
	MaxIdle            int
	IdleTimeoutSeconds int
	MaxActive          int
	Wait               bool
	DB                 int
	// 必填参数
	Network  string
	Address  string
	Password string
}

type Store

type Store interface {
	// redis sadd 命令格式:SADD key member [member ...]
	SAdd(ctx context.Context, key, val string) (int, error)

	// redis EVAL 命令格式: EVAL script numkeys [key [key ...]] [arg [arg ...]]
	// numkeys 参数通过len(keys) 自动计算
	Eval(ctx context.Context, src string, keys []string, args []interface{}) (interface{}, error)
}

Store 表示 redis 存储接口

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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