goRedis

package
v0.0.0-...-41c7706 Latest Latest
Warning

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

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

Documentation

Overview

Package goRedis: GoRedis https://juejin.cn/post/7027347979065360392#heading-34

Index

Constants

View Source
const ErrorClientIsNil = "Redis Client is nil. "

ErrorClientIsNil 当对应当Client指针为空时抛出的错误。

View Source
const ErrorDuplicateKey = "Duplicate key. "

ErrorDuplicateKey 当尝试创建某键值对时,如已存在对应键名抛出的错误。

View Source
const ErrorNotFound = "redis: nil"

ErrorNotFound 中数据查询为空时的返回值。

View Source
const ErrorWIP = "This function is Working in Progress. "

ErrorWIP 调用正在开发的函数将会抛出此错误。

View Source
const StatusDeleted = 1

StatusDeleted 正常删除的返回值。

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayResult

type ArrayResult struct {
	Status bool
	Info   []string
	Err    error
}

ArrayResult 字符串数组结果封装。

func ArrayResultPointer

func ArrayResultPointer() *ArrayResult

ArrayResultPointer 字符串数组结果返回封装。

type Client

type Client struct {
	Address  string        `json:"address"`
	Password string        `json:"password"`
	Database int           `json:"database"`
	ReadOnly bool          `json:"read_only"`
	Args     []interface{} `json:"args"`
	Client   *redis.Client `json:"client"`
	TLS      *tls.Config   `json:"tls"`
}

Client 封装客户端所需参数的结构体。

func (*Client) AppendString

func (cli *Client) AppendString(key string, value string) *Result

AppendString 字符串值追加。

func (*Client) BGSave

func (cli *Client) BGSave()

BGSave 数据持久化存储。

func (*Client) CheckClient

func (cli *Client) CheckClient() error

CheckClient 检查连接。

func (*Client) Close

func (cli *Client) Close() error

Close 关闭数据库连接。

func (*Client) Connect

func (cli *Client) Connect() error

Connect 客户端连接函数,大部分采取默认配置。

func (*Client) ConnectCustom

func (cli *Client) ConnectCustom(connect func(client *Client, args []interface{}) error) error

ConnectCustom 客户端连接函数,完全自定义连接方式。

func (*Client) CreateHashKey

func (cli *Client) CreateHashKey(maps string, key string, value interface{}) *Result

func (*Client) CreateString

func (cli *Client) CreateString(key string, value interface{}) *Result

CreateString 创建永久字符串键值对。

func (*Client) CreateStringWithExpire

func (cli *Client) CreateStringWithExpire(key string, value interface{}, expireTime time.Duration) *Result

CreateStringWithExpire 创建带过期时间的字符串键值对。

func (*Client) DecreaseString

func (cli *Client) DecreaseString(key string) *Result

DecreaseString 自减字符串键值。

func (*Client) DecreaseStringByRange

func (cli *Client) DecreaseStringByRange(key string, step int64) *Result

DecreaseStringByRange 根据提供步长自减字符串键值。

func (*Client) DeleteHash

func (cli *Client) DeleteHash(maps string) *Result

func (*Client) DeleteHashKey

func (cli *Client) DeleteHashKey(maps string, key string) *Result

func (*Client) DeleteString

func (cli *Client) DeleteString(key string) *Result

DeleteString 删除对应字符串键值。

func (*Client) DeleteStrings

func (cli *Client) DeleteStrings(keys ...string) *Result

DeleteStrings 删除对应的一组字符串键值。

func (*Client) ExecuteDo

func (cli *Client) ExecuteDo(args ...interface{}) *InterfaceResult

ExecuteDo 直接处理Redis命令。

func (Client) GetAllList

func (cli Client) GetAllList(list string) *ArrayResult

func (*Client) GetClient

func (cli *Client) GetClient() *redis.Client

GetClient 返回对应的Client指针。

func (Client) GetListRange

func (cli Client) GetListRange(list string, start int64, stop int64) *ArrayResult

func (Client) GetListSize

func (cli Client) GetListSize(list string) *Result

func (Client) GetListTrim

func (cli Client) GetListTrim(list string, start int64, stop int64) *Result

func (*Client) GetSetString

func (cli *Client) GetSetString(key string, value interface{}) *Result

GetSetString 字符串键值对读取原有值并更新为输入值。

func (*Client) IncreaseString

func (cli *Client) IncreaseString(key string) *Result

IncreaseString 自增字符串键值。

func (*Client) IncreaseStringByRange

func (cli *Client) IncreaseStringByRange(key string, step int64) *Result

IncreaseStringByRange 根据提供步长自增字符串键值。

func (Client) LeftPopList

func (cli Client) LeftPopList(list string) *Result

func (Client) LeftPushList

func (cli Client) LeftPushList(list string, key string, value interface{}) *Result

func (*Client) ListHash

func (cli *Client) ListHash(maps string) *MapResult

func (*Client) ListHashKey

func (cli *Client) ListHashKey(maps string) *ArrayResult

func (*Client) ListHashValue

func (cli *Client) ListHashValue(maps string) *ArrayResult

func (*Client) ReadHashKey

func (cli *Client) ReadHashKey(maps string, key string) *Result

func (*Client) ReadString

func (cli *Client) ReadString(key string) *Result

ReadString 获取对应字符串键值。

func (*Client) ReadStringWithExpire

func (cli *Client) ReadStringWithExpire()

ReadStringWithExpire 获取对应字符串键值。

func (*Client) ReadStrings

func (cli *Client) ReadStrings(keys ...string) *InterfaceResult

ReadStrings 获取数个键名对应对键值。

func (Client) RemoveListKey

func (cli Client) RemoveListKey(list string, key string, times int64) *Result

func (Client) RightPopLeftPushList

func (cli Client) RightPopLeftPushList(list string, key string) *Result

func (Client) RightPopList

func (cli Client) RightPopList(list string) *Result

func (Client) RightPushList

func (cli Client) RightPushList(list string, key string, value interface{}) *Result

func (*Client) Save

func (cli *Client) Save()

Save 数据存储。

func (*Client) SearchHashKey

func (cli *Client) SearchHashKey(maps string, pattern string) *ArrayResult

func (*Client) SearchStringWithKey

func (cli *Client) SearchStringWithKey(pattern string) *ArrayResult

SearchStringWithKey 字符串按键名搜索。

func (*Client) UpdateHashKey

func (cli *Client) UpdateHashKey(maps string, key string, value interface{}) *Result

func (Client) UpdateList

func (cli Client) UpdateList(list string, key int64, value interface{}) *Result

func (*Client) UpdateString

func (cli *Client) UpdateString(key string, value interface{}) *Result

UpdateString 更新字符串键值对。

func (*Client) UpdateStringExpire

func (cli *Client) UpdateStringExpire(key string, expireTime time.Duration) *Result

UpdateStringExpire 更新字符串超时时间。

func (*Client) UpdateStringWithExpire

func (cli *Client) UpdateStringWithExpire(key string, value interface{}, expireTime time.Duration) *Result

UpdateStringWithExpire 更新带过期时间带字符串键值对。

type InterfaceResult

type InterfaceResult struct {
	Status bool
	Info   interface{}
	Err    error
}

InterfaceResult 任意类型结果返回封装。

func InterfaceResultPointer

func InterfaceResultPointer() *InterfaceResult

InterfaceResultPointer 任意类型空结果指针。

type MapResult

type MapResult struct {
	Status bool
	Info   map[string]string
	Err    error
}

MapResult 字符串Map结果封装。

func MapResultPointer

func MapResultPointer() *MapResult

type Result

type Result struct {
	Status bool
	Info   string
	Err    error
}

Result 返回结果封装。

func ResultPointer

func ResultPointer() *Result

ResultPointer 空结果指针。

Jump to

Keyboard shortcuts

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