redis

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Redis

type Redis struct {
	Config *redis.Options
	Client *redis.Client
}

Redis provides a cache backed by a Redis server.

func New

func New(config *redis.Options) *Redis

New returns an initialized Redis cache object.

func (*Redis) DecrBy

func (r *Redis) DecrBy(key string, value int64) (int64, error)

DecrBy returns the value saved under a given key.

func (*Redis) Del added in v1.2.2

func (r *Redis) Del(key ...string) error

Del 尾添加一个值为value的元素

func (*Redis) Delete

func (r *Redis) Delete(key string) error

Delete removes a specific key and its value from the Redis server.

func (*Redis) Do

func (r *Redis) Do(cmd, key, seconds string) error

func (*Redis) Expire

func (r *Redis) Expire(key string, seconds time.Duration) (bool, error)

Expire 设置过期时间

func (*Redis) Fetch

func (r *Redis) Fetch(key string, fc func() interface{}) (string, error)

Fetch returns the value for the key if it exists or sets and returns the value via the passed function.

func (*Redis) Get

func (r *Redis) Get(key string) (string, error)

Get returns the value saved under a given key.

func (*Redis) GetByte

func (r *Redis) GetByte(key string) ([]byte, error)

GetByte returns the value saved under a given key.

func (*Redis) HDel

func (r *Redis) HDel(key string, field string) error

HDel 返回名称为key的hash中field对应的value

func (*Redis) HExists

func (r *Redis) HExists(key string, field string) (bool, error)

HExists 返回名称为key的hash中field对应的value

func (*Redis) HGet

func (r *Redis) HGet(key string, field string) (string, error)

HGet 返回名称为key的hash中field对应的value

func (*Redis) HGetall

func (r *Redis) HGetall(key string) (map[string]string, error)

HGetall 返回名称为key的hash中所有的键(field)及其对应的value

func (*Redis) HLen

func (r *Redis) HLen(key string) (int64, error)

HLen 返回名称为key的list的长度

func (*Redis) HMSet

func (r *Redis) HMSet(key string, fields map[string]interface{}) error

HMSet 向名称为map的hash中添加元素field

func (*Redis) HSet

func (r *Redis) HSet(key string, field string, value interface{}) error

HSet 向名称为key的hash中添加元素field

func (*Redis) IncrBy

func (r *Redis) IncrBy(key string, value int64) (int64, error)

IncrBy returns the value saved under a given key.

func (*Redis) Keys added in v1.2.7

func (r *Redis) Keys(pattern string) ([]string, error)

Get returns the value saved under a given key.

func (*Redis) LIndex

func (r *Redis) LIndex(key string, index int64) (string, error)

LIndex 返回名称为key的list中index位置的元素

func (*Redis) LLen

func (r *Redis) LLen(key string) (int64, error)

LLen 返回名称为key的list的长度

func (*Redis) LPop added in v1.2.2

func (r *Redis) LPop(key string) (string, error)

RPush 在名称为key的list尾添加一个值为value的元素

func (*Redis) LPush

func (r *Redis) LPush(key string, value interface{}) error

LPush 在名称为key的list头添加一个值为value的 元素

func (*Redis) LRange added in v1.2.1

func (r *Redis) LRange(key string) ([]string, error)

LRange 对应RPush获取值 在名称为key的list尾添加一个值为value的元素

func (*Redis) LRem added in v1.2.1

func (r *Redis) LRem(key string, value interface{}) error

LRem 在名称为key的list 删除 一个值为value的元素

func (*Redis) LSet

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

LSet 给名称为key的list中index位置的元素赋值

func (*Redis) RPush

func (r *Redis) RPush(key string, value ...interface{}) error

RPush 在名称为key的list尾添加一个值为value的元素

func (*Redis) SAdd

func (r *Redis) SAdd(key string, members ...interface{}) error

SAdd 向名称为key的set中添加元素member

func (*Redis) SCard added in v1.2.5

func (r *Redis) SCard(key string) (int64, error)

SCard 获取元素的数量

func (*Redis) SIsMember added in v1.2.2

func (r *Redis) SIsMember(key string, field string) (bool, error)

使用Redis的原子操作检查账户ID是否已存在于列表中

func (*Redis) SMembers added in v1.2.4

func (r *Redis) SMembers(key string) ([]string, error)

SMembers 向名称为key的获取所有元素

func (*Redis) SRandMember

func (r *Redis) SRandMember(key string) (string, error)

SCard 返回名称为key的set的元素个数

func (*Redis) SRem added in v1.2.2

func (r *Redis) SRem(key string, members ...interface{}) error

SRem 从名称为key的set中删除元素member

func (*Redis) Scan added in v1.2.6

func (r *Redis) Scan(cursor uint64, match string, count int64) ([]string, uint64, error)

使用 SCAN 命令扫描匹配的键

func (*Redis) Set

func (r *Redis) Set(key string, value interface{}) error

Set saves an arbitrary value under a specific key.

func (*Redis) Unmarshal

func (r *Redis) Unmarshal(key string, object interface{}) error

Unmarshal retrieves a value from the Redis server and unmarshals it into the passed object.

func (*Redis) ZAdd added in v1.2.2

func (r *Redis) ZAdd(key string, members ...redis.Z) error

ZAdd 是 Redis 的一个有序集合命令,更新操作,如果某个成员已经是有序集的成员,那么更新这个成员的分数值,并通过重新插入这个成员元素,来保证该成员在正确的位置上。

func (*Redis) ZRangeWithScores added in v1.2.2

func (r *Redis) ZRangeWithScores(key string, start, stop int64) ([]redis.Z, error)

ZRange 是 Redis 的一个有序集合命令,用于按照指定范围获取有序集合中的元素。

Jump to

Keyboard shortcuts

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