dbredis

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	Address: "localhost:6379",
	Timeout: &defaultTimeout,
}
View Source
var NilErr = errors.New("nil")

NilErr represents redis nil

Functions

func AddKeyValue

func AddKeyValue(key, value string) error

setKeyValueWithoutExpiration 添加键值对到Redis(不携带过期时间)

func AddKeyValueWithExpiration

func AddKeyValueWithExpiration(key string, value interface{}, expiration time.Duration) error

setStructWithExpiration 添加带有过期时间的结构体到键

func AddMultipleToSet

func AddMultipleToSet(key string, members ...interface{}) error

addMultipleToSet 批量添加元素到集合

func AddMultipleToSetWithExpiration

func AddMultipleToSetWithExpiration(key string, expiration time.Duration, members ...interface{}) error

addToSetWithExpiration 批量添加元素到集合并设置过期时间

func AddToSet

func AddToSet(key string, member interface{}) error

addToSetWithExpiration 向集合中添加元素

func AddToSetWithExpiration

func AddToSetWithExpiration(key string, member interface{}, expiration time.Duration) error

addToSetWithExpiration 向集合中添加元素并设置过期时间

func Client

func Client() *redis.Client

func Close

func Close() error

func GetKeyValue

func GetKeyValue(key string, value interface{}) error

getStruct 获取键的结构体值

func GetSetMembers

func GetSetMembers(key string) ([]string, error)

getSetMembers 获取集合中的所有元素

func Init

func Init() error

func IsMemberOfSet

func IsMemberOfSet(key string, member interface{}) (bool, error)

isMemberOfSet 检查元素是否属于集合

func NewClient

func NewClient() (*redis.Client, error)

func RemoveAllFromSet

func RemoveAllFromSet(key string) error

deleteAllSetElements 删除集合中所有元素

func RemoveFromSet

func RemoveFromSet(key string, member interface{}) error

removeFromSet 从集合中删除元素

Types

type Options

type Options struct {
	// Address of the Redis server, including the port.
	// Optional ("localhost:6379" by default).
	Address string
	// Password for the Redis server.
	// Optional ("" by default).
	Password string
	// DB to use.
	// Optional (0 by default).
	DB int
	// The timeout for operations.
	// Optional (2 * time.Second by default).
	Timeout *time.Duration
}

Options are the options for the Redis client.

func GetRedisOptions

func GetRedisOptions() Options

Jump to

Keyboard shortcuts

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