redis

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

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

Go to latest
Published: Apr 16, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Pool *redis.Pool
}

Client redis client

func (*Client) Del

func (pool *Client) Del(key ...interface{}) (num int, err error)

Del 可以删除多个key 返回删除key的num和错误

func (*Client) EXISTS

func (pool *Client) EXISTS(key string) (ok bool, err error)

EXISTS redis exist

func (*Client) EXPIRE

func (pool *Client) EXPIRE(key string, expireTime int) (num int, err error)

EXPIRE 设置一个key 的过期时间 返回值int 1 如果设置了过期时间 0 如果没有设置过期时间,或者不能设置过期时间

func (*Client) EXPIREAT

func (pool *Client) EXPIREAT(key string, expireAtTime int64) (num int, err error)

EXPIREAT 设置一个key 的在指定时间过期 返回值:如果生存时间设置成功,返回 1 ;当 key 不存在或没办法设置生存时间,返回 0 。

func (*Client) GETBIT

func (pool *Client) GETBIT(key string, bit int) (ret int, err error)

GETBIT 获取指定偏移量上的位(bit)

func (*Client) Get

func (pool *Client) Get(key string) (s string, err error)

Get redis get return string

func (*Client) GetInt

func (pool *Client) GetInt(key string) (n int, err error)

GetInt redis get return int

func (*Client) GetInt64

func (pool *Client) GetInt64(key string) (n int64, err error)

GetInt64 redis get return int64

func (*Client) GetSearchKeys

func (pool *Client) GetSearchKeys(key string, limit int) (list []string, err error)

GetSearchKeys ZREVRANGEBYSCORE 逆序份数 获取的 前N个数据 不要scores

func (*Client) GetSearchKeys2

func (pool *Client) GetSearchKeys2(key string, start, len int) (list []string, err error)

GetSearchKeys2 ZREVRANGEBYSCORE 逆序份数 获取的 start,len 不要scores

func (*Client) GetSet

func (pool *Client) GetSet(key string, value interface{}) (s string, err error)

GetSet 将键 key 的值设为 value , 并返回键 key 在被设置之前的旧值。

func (*Client) HEXISTS

func (pool *Client) HEXISTS(key, field string) (ok bool, err error)

HEXISTS 检查给定域 field 是否存在于哈希表 hash 当中。

func (*Client) HGET

func (pool *Client) HGET(key, field string) (out string, err error)

HGET 该字段所关联的值。当字段不存在或者 key 不存在时返回nil。

func (*Client) HGETALLMAP

func (pool *Client) HGETALLMAP(key string) (interface{}, error)

HGETALLMAP 返回hash表中所有字段

func (*Client) HINCRBY

func (pool *Client) HINCRBY(key, field string, in int) (num int, err error)

HINCRBY 增值操作执行后的该字段的值。

func (*Client) HKEYS

func (pool *Client) HKEYS(key string) (data []string, err error)

HKEYS 返回哈希表 key 中的所有域

func (*Client) HLEN

func (pool *Client) HLEN(key string) (num int, err error)

HLEN 哈希集中字段的数量,当 key 指定的哈希集不存在时返回 0

func (*Client) HMGET

func (pool *Client) HMGET(key, feild string) (data []string, err error)

HMGET 返回哈希表 key 中,一个或多个给定域的值。 如果给定的域不存在于哈希表,那么返回一个 nil 值。 因为不存在的 key 被当作一个空哈希表来处理,所以对一个不存在的 key 进行 HMGET 操作将返回一个只带有 nil 值的表。

func (*Client) HMGET2

func (pool *Client) HMGET2(key string, feild ...string) (data []string, err error)

HMGET2 返回哈希表 key 中,一个或多个给定域的值。 如果给定的域不存在于哈希表,那么返回一个 nil 值。 因为不存在的 key 被当作一个空哈希表来处理,所以对一个不存在的 key 进行 HMGET 操作将返回一个只带有 nil 值的表。

func (*Client) HMGETINT64MAP

func (pool *Client) HMGETINT64MAP(key string) (map[string]int64, error)

HMGETINT64MAP 返回hash表中所有字段 并映射为map[string]int64

func (*Client) HMGETINTMAP

func (pool *Client) HMGETINTMAP(key string) (map[string]int, error)

HMGETINTMAP 返回hash表中所有字段 并映射为map[string]int

func (*Client) HMGETMAP

func (pool *Client) HMGETMAP(key string) (map[string]string, error)

HMGETMAP 返回hash表中所有字段 并映射为map[string]string

func (*Client) HMGETSTRUCT

func (pool *Client) HMGETSTRUCT(key, value interface{}) (err error)

HMGETSTRUCT 返回hash表中所有字段 并映射为结构体

func (*Client) HMSET

func (pool *Client) HMSET(key, value interface{}) (ok string, err error)

HMSET 同时将多个 field-value (域-值)对设置到哈希表 key 中。 此命令会覆盖哈希表中已存在的域。 如果 key 不存在,一个空哈希表被创建并执行 HMSET 操作。

func (*Client) HMSETArgs

func (pool *Client) HMSETArgs(key string, node interface{}) error

HMSETArgs HMSET args

func (*Client) HSET

func (pool *Client) HSET(key, field string, value interface{}) (ok bool, err error)

HSET 1如果field是一个新的字段 0如果field原来在map里面已经存在

func (*Client) INCR

func (pool *Client) INCR(key string) (err error)

INCR 为键 key 储存的数字值加上一。 如果键 key 不存在, 那么它的值会先被初始化为 0 , 然后再执行 INCR 命令。 如果键 key 储存的值不能被解释为数字, 那么 INCR 命令将返回一个错误。 本操作的值限制在 64 位(bit)有符号数字表示之内。

func (*Client) INCRRET

func (pool *Client) INCRRET(key string) (num int, err error)

INCRRET INCR 为键 key 储存的数字值加上一。 如果键 key 不存在, 那么它的值会先被初始化为 0 , 然后再执行 INCR 命令。 如果键 key 储存的值不能被解释为数字, 那么 INCR 命令将返回一个错误。 本操作的值限制在 64 位(bit)有符号数字表示之内。

func (*Client) KEYS

func (pool *Client) KEYS(pattern string) (keys []string, err error)

KEYS redis range key

func (*Client) LINDEX

func (pool *Client) LINDEX(key string, index int) (out string, err error)

LINDEX 当 key 位置的值不是一个列表的时候,会返回一个error

func (*Client) LPOP

func (pool *Client) LPOP(key string) (out string, err error)

LPOP 移除并返回列表 key 的头元素。

func (*Client) LPUSH

func (pool *Client) LPUSH(key string, value ...interface{}) (num int, err error)

LPUSH 整型回复: 在 push 操作后的 list 长度。

func (*Client) Lock

func (pool *Client) Lock(key string, timeout int) (locked bool, expiredTime int64, err error)

Lock redis 实现的分布式锁 lock

func (*Client) LockMust

func (pool *Client) LockMust(key string, timeout int) (locked bool, expiredTime int64, err error)

LockMust redis 实现的分布式锁 lock must

func (*Client) LockRetry

func (pool *Client) LockRetry(key string, timeout, retryTimes int) (locked bool, expiredTime int64, err error)

LockRetry redis 实现的分布式锁 lock retry

func (*Client) SADD

func (pool *Client) SADD(key string, value interface{}) (num int, err error)

SADD 可以添加多个 返回成功数量

func (*Client) SCARD

func (pool *Client) SCARD(key string) (num int, err error)

SCARD redis 返回集合中元素的数量

func (*Client) SETBIT

func (pool *Client) SETBIT(key string, bit, value int) (ret int, err error)

SETBIT 对 key 所储存的字符串值,设置或清除指定偏移量上的位(bit)。 位的设置或清除取决于 value 参数,可以是 0 也可以是 1 。 当 key 不存在时,自动生成一个新的字符串值。 字符串会进行伸展(grown)以确保它可以将 value 保存在指定的偏移量上。当字符串值进行伸展时,空白位置以 0 填充。

func (*Client) SETEX

func (pool *Client) SETEX(key string, seconds int, value interface{}) (err error)

SETEX key seconds value

func (*Client) SISMEMBER

func (pool *Client) SISMEMBER(key string, value interface{}) (ok bool, err error)

SISMEMBER 判断成员元素是否是集合的成员

func (*Client) SMEMBERS

func (pool *Client) SMEMBERS(key string) (reply []string, err error)

SMEMBERS 返回集合 key 中的所有成员。 不存在的 key 被视为空集合。

func (*Client) SPOP

func (pool *Client) SPOP(key string) (out string, err error)

SPOP 弹出被移除的元素, 当key不存在的时候返回 nil

func (*Client) SREM

func (pool *Client) SREM(key string, value interface{}) (num int, err error)

SREM 移除集合 key 中的一个或多个 member 元素,不存在的 member 元素会被忽略 当 key 不是集合类型,返回一个错误。

func (*Client) Set

func (pool *Client) Set(key string, value interface{}) (err error)

Set 总是成功的

func (*Client) SetNX

func (pool *Client) SetNX(key string, value interface{}) (err error)

SetNX 不存在则设置,存在则不设置

func (*Client) SetNX2

func (pool *Client) SetNX2(key string, value interface{}) (num int, err error)

SetNX2 不存在则设置,存在则不设置

func (*Client) TTL

func (pool *Client) TTL(key string) (ttl int, err error)

TTL key 以秒为单位,返回给定 key 的剩余生存时间(TTL, time to live)。

func (*Client) UnLock

func (pool *Client) UnLock(key string, safeDelTime int64) (bool, error)

UnLock redis 实现的分布式锁 unlock

func (pool *Client) Unlink(key ...interface{}) (num int, err error)

Unlink like delete redis 4.0 +

func (*Client) ZADD

func (pool *Client) ZADD(key string, sorce int, member string) (num int, err error)

ZADD 将一个或多个 member 元素及其 score 值加入到有序集 key 当中。 如果某个 member 已经是有序集的成员,那么更新这个 member 的 score 值,并通过重新插入这个 member 元素,来保证该 member 在正确的位置上。

func (*Client) ZCARD

func (pool *Client) ZCARD(key string) (num int, err error)

ZCARD cz

func (*Client) ZFADD

func (pool *Client) ZFADD(key string, sorce float64, member string) (num int, err error)

ZFADD ZADD float64

func (*Client) ZFSCORE

func (pool *Client) ZFSCORE(key string, member string) (num float64, err error)

ZFSCORE ZSCORE cz

func (*Client) ZINCRBY

func (pool *Client) ZINCRBY(key string, increment int, member string) (num int, err error)

ZINCRBY +increment 如果没有key 插入

func (*Client) ZRANGE

func (pool *Client) ZRANGE(key string, start, stop int) (list []string, err error)

ZRANGE cz

func (*Client) ZRANK

func (pool *Client) ZRANK(key string, member string) (num int, err error)

ZRANK 判断一个member 在key中的索引 如果不在 返回nil ,在 返回索引

func (*Client) ZREM

func (pool *Client) ZREM(key string, member string) (num int, err error)

ZREM cz

func (*Client) ZREMRANGEBYRANK

func (pool *Client) ZREMRANGEBYRANK(key string, stop int) (num int, err error)

ZREMRANGEBYRANK myzset 0 1 0 -200(保留200名)

func (*Client) ZREVRANGE

func (pool *Client) ZREVRANGE(key string, start, stop int) (list []string, err error)

ZREVRANGE cz

func (*Client) ZREVRANGEBYSCORE

func (pool *Client) ZREVRANGEBYSCORE(key string, limit int) (list map[string]string, err error)

ZREVRANGEBYSCORE 逆序份数 获取的 前N个数据

func (*Client) ZREVRANGEBYSCORE2

func (pool *Client) ZREVRANGEBYSCORE2(key string, start, len int) (list map[string]int, err error)

ZREVRANGEBYSCORE2 ZREVRANGEBYSCORE 逆序份数 获取start len的数据

func (*Client) ZREVRANGEBYSCORE3

func (pool *Client) ZREVRANGEBYSCORE3(key string, start, len int) (list map[string]float64, err error)

ZREVRANGEBYSCORE3 ZREVRANGEBYSCORE 逆序份数 获取start len的数据

func (*Client) ZREVRANK

func (pool *Client) ZREVRANK(key string, member string) (num int, err error)

ZREVRANK cz

func (*Client) ZSCORE

func (pool *Client) ZSCORE(key string, member string) (num int, err error)

ZSCORE cz

Jump to

Keyboard shortcuts

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