redis

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register() common.Caller

Types

type CallerCfg

type CallerCfg struct {
	Debug bool

	Network        string // tcp
	Addr           string // 127.0.0.1:6379
	DB             int
	Password       string
	ConnectTimeout common.Duration
	ReadTimeout    common.Duration
	WriteTimeout   common.Duration

	MaxIdle     int
	MaxActive   int
	IdleTimeout common.Duration
	Wait        bool
}

type Cfg

type Cfg struct {
	Muses struct {
		Redis map[string]CallerCfg `toml:"redis"`
	} `toml:"muses"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func Caller

func Caller(name string) *Client

func Provider added in v0.2.10

func Provider(cfg CallerCfg) (resp *Client)

func (*Client) Blpop

func (r *Client) Blpop(channel string, time interface{}) (interface{}, error)

func (*Client) Decr

func (r *Client) Decr(key string) (val int64, err error)

func (*Client) DecrBy

func (r *Client) DecrBy(key string, amount int) (val int64, err error)

func (*Client) Del

func (r *Client) Del(key string) error

Del 删除键

func (*Client) Do

func (r *Client) Do(commandName string, args ...interface{}) (reply interface{}, err error)

func (*Client) Exists

func (r *Client) Exists(key string) (bool, error)

Exists 检查键是否存在

func (*Client) Expire

func (r *Client) Expire(key string, expire int) error

Expire 设置键过期时间,expire的单位为秒

func (*Client) Flush

func (r *Client) Flush() error

func (*Client) Get

func (r *Client) Get(key string) (interface{}, error)

func (*Client) GetBool

func (r *Client) GetBool(key string) (bool, error)

func (*Client) GetInt

func (r *Client) GetInt(key string) (int, error)

func (*Client) GetInt64

func (r *Client) GetInt64(key string) (int64, error)

func (*Client) GetObject

func (r *Client) GetObject(key string, val interface{}) error

func (*Client) GetString

func (r *Client) GetString(key string) (string, error)

func (*Client) Hget

func (r *Client) Hget(key, field string) (reply interface{}, err error)

Hmget 用法:cache.Myredis.Hget("key", "field_name")

func (*Client) HgetAll

func (r *Client) HgetAll(key string, val interface{}) error

Hmget 用法:cache.Myredis.HgetAll("key", &val)

func (*Client) HgetBool

func (r *Client) HgetBool(key, field string) (reply bool, err error)

func (*Client) HgetInt

func (r *Client) HgetInt(key, field string) (reply int, err error)

func (*Client) HgetInt64

func (r *Client) HgetInt64(key, field string) (reply int64, err error)

func (*Client) HgetObject

func (r *Client) HgetObject(key, field string, val interface{}) error

func (*Client) HgetString

func (r *Client) HgetString(key, field string) (reply string, err error)

func (*Client) Hmset

func (r *Client) Hmset(key string, val interface{}, expire int) (err error)

Hmset 用法:cache.Myredis.Hmset("key", val, 60)

func (*Client) Hset

func (r *Client) Hset(key, field string, val interface{}) (interface{}, error)

func (*Client) Incr

func (r *Client) Incr(key string) (val int64, err error)

func (*Client) IncrBy

func (r *Client) IncrBy(key string, amount int) (val int64, err error)

func (*Client) Publish

func (r *Client) Publish(channel, message string) (int, error)

Publish 将信息发送到指定的频道,返回接收到信息的订阅者数量

func (*Client) Rpush

func (r *Client) Rpush(channel, msg string) (interface{}, error)

func (*Client) Send

func (r *Client) Send(commandName string, args ...interface{}) error

func (*Client) Set

func (r *Client) Set(key string, val interface{}, expire int) (interface{}, error)

Set 用法:Set("key", val, 60),其中 expire 的单位为秒

func (*Client) Ttl

func (r *Client) Ttl(key string) (ttl int64, err error)

TTL 以秒为单位。当 key 不存在时,返回 -2 。 当 key 存在但没有设置剩余生存时间时,返回 -1

func (*Client) Zadd

func (r *Client) Zadd(key string, score int64, member string) (reply interface{}, err error)

Zadd 将一个成员元素及其分数值加入到有序集当中

func (*Client) Zrange

func (r *Client) Zrange(key string, from, to int64) (map[string]int64, error)

Zrange 返回有序集中,指定区间内的成员。其中成员的位置按分数值递增(从小到大)来排序。具有相同分数值的成员按字典序(lexicographical order )来排列。 以 0 表示有序集第一个成员,以 1 表示有序集第二个成员,以此类推。或 以 -1 表示最后一个成员, -2 表示倒数第二个成员,以此类推。

func (*Client) ZrangeByScore

func (r *Client) ZrangeByScore(key string, from, to, offset int64, count int) (map[string]int64, error)

ZrangeByScore 返回有序集合中指定分数区间的成员列表。有序集成员按分数值递增(从小到大)次序排列。 具有相同分数值的成员按字典序来排列

func (*Client) Zrank

func (r *Client) Zrank(key, member string) (int64, error)

Zrank 返回有序集中指定成员的排名。其中有序集成员按分数值递增(从小到大)顺序排列。score 值最小的成员排名为 0

func (*Client) Zrem

func (r *Client) Zrem(key string, member string) (reply interface{}, err error)

Zrem 移除有序集中的一个,不存在的成员将被忽略。

func (*Client) Zrevrange

func (r *Client) Zrevrange(key string, from, to int64) (map[string]int64, error)

Zrevrange 返回有序集中,指定区间内的成员。其中成员的位置按分数值递减(从大到小)来排列。具有相同分数值的成员按字典序(lexicographical order )来排列。 以 0 表示有序集第一个成员,以 1 表示有序集第二个成员,以此类推。或 以 -1 表示最后一个成员, -2 表示倒数第二个成员,以此类推。

func (*Client) ZrevrangeByScore

func (r *Client) ZrevrangeByScore(key string, from, to, offset int64, count int) (map[string]int64, error)

ZrevrangeByScore 返回有序集中指定分数区间内的所有的成员。有序集成员按分数值递减(从大到小)的次序排列。 具有相同分数值的成员按字典序来排列

func (*Client) Zrevrank

func (r *Client) Zrevrank(key, member string) (int64, error)

Zrevrank 返回有序集中成员的排名。其中有序集成员按分数值递减(从大到小)排序。分数值最大的成员排名为 0 。

func (*Client) Zscore

func (r *Client) Zscore(key string, member string) (int64, error)

Zscore 返回有序集中,成员的分数值。 如果成员元素不是有序集 key 的成员,或 key 不存在,返回 nil

Jump to

Keyboard shortcuts

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