redis

package
v0.0.0-...-e1367df Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BLPop

func BLPop(timeout time.Duration, keys ...string) ([]string, error)

从key的列表值中移出并获取列表的第一个元素,如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。

func BRPop

func BRPop(timeout time.Duration, keys ...string) ([]string, error)

从key的列表值中移出并获取列表的最后一个元素,如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。

func BRPopLPush

func BRPopLPush(source string, destination string, timeout time.Duration) (string, error)

从source列表中弹出一个值,将弹出的元素插入到destination列表中并返回它; 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。

func Decr

func Decr(key string) (int64, error)

对key的value值减量减1(整型,返回减量后的值)

func DecrBy

func DecrBy(key string, decrement int64) (int64, error)

对key的value值减量减指定值(整型,返回减量后的值)

func Del

func Del(keys ...string) error

删除缓存数据(返回删除数量)

func Engine

func Engine() *redis.Client

返回客户端引擎

func Exists

func Exists(keys ...string) (int64, error)

判断key是否存在(返回存在数量)

func Get

func Get(key string) (result string, err error)

获取key-value数据

func GetSet

func GetSet(key string, value interface{}) (result string, err error)

缓存key-value数据,并返回key的旧值

func Incr

func Incr(key string) (int64, error)

对key的value值增量加1(整型,返回增量后的值)

func IncrBy

func IncrBy(key string, value int64) (int64, error)

对key的value值增量加指定值(整型,返回增量后的值)

func IncrByFloat

func IncrByFloat(key string, value float64) (float64, error)

对key的value值增量加指定值(浮点型,返回增量后的值)

func LIndex

func LIndex(key string, index int64) (string, error)

通过索引获取列表中的元素

func LInsert

func LInsert(key string, op string, pivot interface{}, value interface{}) error

在key列表的pivot元素前或者后插入value元素(op取值范围为:BEFORE | AFTER)

func LLen

func LLen(key string) (int64, error)

获取列表长度

func LPop

func LPop(key string) (string, error)

移出并获取列表的第一个元素

func LPush

func LPush(key string, values ...interface{}) error

将一个或多个值插入到列表头部

func LPushX

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

将一个值插入到已存在的列表头部

func LRange

func LRange(key string, start int64, stop int64) ([]string, error)

获取列表指定范围内的元素

func LRem

func LRem(key string, count int64, value interface{}) error

* 移除列表元素 * * count > 0 : 从表头开始向表尾搜索,移除与 value 相等的元素,数量为 count * count < 0 : 从表尾开始向表头搜索,移除与 value 相等的元素,数量为 count 的绝对值 * count = 0 : 移除表中所有与 value 相等的值。

func LSet

func LSet(key string, index int64, value interface{}) error

通过索引index设置列表元素的value值

func LTrim

func LTrim(key string, start int64, stop int64) error

对一个列表进行修剪(trim),让列表只保留指定区间内的元素,不在指定区间之内的元素都将被删除。

func Ping

func Ping() (string, error)

Ping

func RPop

func RPop(key string) (string, error)

移除列表的最后一个元素,返回值为移除的元素。

func RPopLPush

func RPopLPush(source string, destination string) (string, error)

移除source列表的最后一个元素,并将该元素添加到destination列表并返回

func RPush

func RPush(key string, values ...interface{}) error

在列表中添加一个或多个值

func RPushX

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

为已存在的列表添加值

func Set

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

缓存key-value数据

func SetNX

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

当key不存在时才缓存key-value数据(返回是否保存了缓存)

func TTL

func TTL(key string) (time.Duration, error)

获取key的有效期

Types

This section is empty.

Jump to

Keyboard shortcuts

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