redis

package
v0.0.0-...-2be3143 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store interface {
	// 字符串
	Set(key string, value interface{}, expiration time.Duration) error
	Get(key string) (string, error)
	Incr(key string) (int64, error)
	Decr(key string) (int64, error)
	Del(key string) error
	Exists(key string) (bool, error)
	Expire(key string, expiration time.Duration) error

	// 哈希
	HSet(key string, values ...interface{}) error
	HGet(key, field string) (string, error)
	HGetAll(key string) (map[string]string, error)
	HDel(key string, fields ...string) error

	// 列表
	LPush(key string, values ...interface{}) error
	RPop(key string) (string, error)

	// 集合
	SAdd(key string, members ...interface{}) error
	SMembers(key string) ([]string, error)
	SRem(key string, members ...interface{}) error

	// 分布式锁
	TryLock(key, value string, expiration time.Duration) (bool, error)
	Unlock(key string) error

	// Lua 脚本
	Eval(script string, keys []string, args ...interface{}) (interface{}, error)
}

Store 定义对 Redis 的常用操作接口

func NewRedisClient

func NewRedisClient() Store

NewRedisClient 创建一个 Redis 封装实例

Jump to

Keyboard shortcuts

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