Documentation
¶
Index ¶
- Variables
- type Config
- type Message
- type RedisClient
- func (r *RedisClient) Close()
- func (r *RedisClient) Del(keys ...string) error
- func (r *RedisClient) Expire(key string, expiration time.Duration) (bool, error)
- func (r *RedisClient) Get(key string) (string, error)
- func (r *RedisClient) HDel(key string, field ...string) error
- func (r *RedisClient) HGet(key string, field string) (string, error)
- func (r *RedisClient) HGetAll(key string) (map[string]string, error)
- func (r *RedisClient) HSet(key, field string, val interface{}, expiration ...time.Duration) error
- func (r *RedisClient) Pub(channel string, msg string) error
- func (r *RedisClient) Set(key string, value interface{}, expiration ...time.Duration) error
- func (r *RedisClient) Sub(channel string, handler func(*Message))
Constants ¶
This section is empty.
Variables ¶
View Source
var RedisTTL = time.Hour * 24
RedisTTL 默认有效期 24 小时
Functions ¶
This section is empty.
Types ¶
type RedisClient ¶
type RedisClient struct { Namespace string Client redis.UniversalClient Prefix string // contains filtered or unexported fields }
RedisClient redis client wrapper
func (*RedisClient) HDel ¶
func (r *RedisClient) HDel(key string, field ...string) error
HDel 删除hash的键
func (*RedisClient) HGet ¶
func (r *RedisClient) HGet(key string, field string) (string, error)
HGet 获取 Hash 的字段值
func (*RedisClient) HGetAll ¶
func (r *RedisClient) HGetAll(key string) (map[string]string, error)
HGetAll 获取 Hash 的所有字段
func (*RedisClient) HSet ¶
func (r *RedisClient) HSet(key, field string, val interface{}, expiration ...time.Duration) error
HSet 设置hash值
func (*RedisClient) Pub ¶
func (r *RedisClient) Pub(channel string, msg string) error
Pub 发布事件 example: Redis.Pub("chat", "this is a test message")
func (*RedisClient) Set ¶
func (r *RedisClient) Set(key string, value interface{}, expiration ...time.Duration) error
Set 设置字符串值,有效期默认 24 小时
func (*RedisClient) Sub ¶
func (r *RedisClient) Sub(channel string, handler func(*Message))
Sub 监听通道,有数据时触发回调 handler example:
redis.Sub("chat")(func(msg *redis.Message) { fmt.Printf("receive message: %#v", msg) })
Click to show internal directories.
Click to hide internal directories.