Documentation
¶
Index ¶
- Constants
- type Config
- type Redis
- func (r *Redis) Close() (err error)
- func (r *Redis) Cluster() *redis.ClusterClient
- func (r *Redis) Decr(key string) bool
- func (r *Redis) Del(key string) int64
- func (r *Redis) DelWithErr(key string) (int64, error)
- func (r *Redis) Exists(key string) bool
- func (r *Redis) ExistsWithErr(key string) (bool, error)
- func (r *Redis) Expire(key string, expiration time.Duration) (bool, error)
- func (r *Redis) GeoAdd(key string, location *redis.GeoLocation) (int64, error)
- func (r *Redis) GeoRadius(key string, longitude, latitude float64, query *redis.GeoRadiusQuery) ([]redis.GeoLocation, error)
- func (r *Redis) Get(key string) string
- func (r *Redis) GetRaw(key string) ([]byte, error)
- func (r *Redis) HDel(key string, field ...string) bool
- func (r *Redis) HGet(key string, fields string) (string, error)
- func (r *Redis) HGetAll(key string) map[string]string
- func (r *Redis) HIncrBy(key string, field string, incr int) int64
- func (r *Redis) HIncrByWithErr(key string, field string, incr int) (int64, error)
- func (r *Redis) HKeys(key string) []string
- func (r *Redis) HLen(key string) int64
- func (r *Redis) HMGet(key string, fileds []string) []string
- func (r *Redis) HMGetMap(key string, fields []string) map[string]string
- func (r *Redis) HMSet(key string, hash map[string]interface{}, expire time.Duration) bool
- func (r *Redis) HSet(key string, field string, value interface{}) bool
- func (r *Redis) Incr(key string) bool
- func (r *Redis) IncrBy(key string, increment int64) (int64, error)
- func (r *Redis) IncrWithErr(key string) (int64, error)
- func (r *Redis) LIndex(key string, idx int64) (string, error)
- func (r *Redis) LLen(key string) int64
- func (r *Redis) LLenWithErr(key string) (int64, error)
- func (r *Redis) LPush(key string, values ...interface{}) (int64, error)
- func (r *Redis) LRange(key string, start, stop int64) ([]string, error)
- func (r *Redis) LRem(key string, count int64, value interface{}) int64
- func (r *Redis) LTrim(key string, start, stop int64) (string, error)
- func (r *Redis) MGet(keys ...string) ([]string, error)
- func (r *Redis) MGets(keys []string) ([]interface{}, error)
- func (r *Redis) RPop(key string) (string, error)
- func (r *Redis) RPush(key string, values ...interface{}) (int64, error)
- func (r *Redis) SAdd(key string, member ...interface{}) (int64, error)
- func (r *Redis) SIsMember(key string, member interface{}) (bool, error)
- func (r *Redis) SMembers(key string) ([]string, error)
- func (r *Redis) Set(key string, value interface{}, expire time.Duration) bool
- func (r *Redis) SetNx(key string, value interface{}, expiration time.Duration) bool
- func (r *Redis) SetNxWithErr(key string, value interface{}, expiration time.Duration) (bool, error)
- func (r *Redis) SetWithErr(key string, value interface{}, expire time.Duration) error
- func (r *Redis) Stub() *redis.Client
- func (r *Redis) TTL(key string) (int64, error)
- func (r *Redis) Type(key string) (string, error)
- func (r *Redis) ZAdd(key string, members ...redis.Z) (int64, error)
- func (r *Redis) ZCard(key string) (int64, error)
- func (r *Redis) ZCount(key string, min, max string) (int64, error)
- func (r *Redis) ZRange(key string, start, stop int64) ([]string, error)
- func (r *Redis) ZRem(key string, members ...interface{}) (int64, error)
- func (r *Redis) ZRemRangeByRank(key string, start, stop int64) (int64, error)
- func (r *Redis) ZRevRange(key string, start, stop int64) ([]string, error)
- func (r *Redis) ZRevRangeByScore(key string, opt redis.ZRangeBy) ([]string, error)
- func (r *Redis) ZRevRangeByScoreWithScores(key string, opt redis.ZRangeBy) ([]redis.Z, error)
- func (r *Redis) ZRevRangeWithScores(key string, start, stop int64) ([]redis.Z, error)
- func (r *Redis) ZRevRank(key string, member string) (int64, error)
- func (r *Redis) ZScore(key string, member string) (float64, error)
Constants ¶
View Source
const ( //ClusterMode using clusterClient ClusterMode string = "cluster" //StubMode using reidsClient StubMode string = "stub" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Addrs 实例配置地址
Addrs []string `json:"addrs"`
// Addr stubConfig 实例配置地址
Addr string `json:"addr"`
// Mode Redis模式 cluster|stub
Mode string `json:"mode"`
// Password 密码
Password string `json:"password"`
// DB,默认为0, 一般应用不推荐使用DB分片
DB int `json:"db"`
// PoolSize 集群内每个节点的最大连接池限制 默认每个CPU10个连接
PoolSize int `json:"poolSize"`
// MaxRetries 网络相关的错误最大重试次数 默认8次
MaxRetries int `json:"maxRetries"`
// MinIdleConns 最小空闲连接数
MinIdleConns int `json:"minIdleConns"`
// DialTimeout 拨超时时间
DialTimeout time.Duration `json:"dialTimeout"`
// ReadTimeout 读超时 默认3s
ReadTimeout time.Duration `json:"readTimeout"`
// WriteTimeout 读超时 默认3s
WriteTimeout time.Duration `json:"writeTimeout"`
// IdleTimeout 连接最大空闲时间,默认60s, 超过该时间,连接会被主动关闭
IdleTimeout time.Duration `json:"idleTimeout"`
// Debug开关
Debug bool `json:"debug"`
// ReadOnly 集群模式 在从属节点上启用读模式
ReadOnly bool `json:"readOnly"`
// 是否开启链路追踪,开启以后。使用DoCotext的请求会被trace
EnableTrace bool `json:"enableTrace"`
// 慢日志门限值,超过该门限值的请求,将被记录到慢日志中
SlowThreshold time.Duration `json:"slowThreshold"`
// OnDialError panic|error
OnDialError string `json:"level"`
// contains filtered or unexported fields
}
Config for redis, contains RedisStubConfig and RedisClusterConfig
func RawRedisClusterConfig ¶
RawRedisClusterConfig ...
func StdRedisClusterConfig ¶
StdRedisClusterConfig ...
type Redis ¶
Redis client (cmdable and config)
func (*Redis) Close ¶
Close closes the cluster client, releasing any open resources.
It is rare to Close a ClusterClient, as the ClusterClient is meant to be long-lived and shared between many goroutines.
func (*Redis) Cluster ¶
func (r *Redis) Cluster() *redis.ClusterClient
Cluster try to get a redis.ClusterClient
func (*Redis) ExistsWithErr ¶
ExistsWithErr ...
func (*Redis) GeoRadius ¶
func (r *Redis) GeoRadius(key string, longitude, latitude float64, query *redis.GeoRadiusQuery) ([]redis.GeoLocation, error)
GeoRadius 根据经纬度查询列表
func (*Redis) HIncrByWithErr ¶
HIncrByWithErr 哈希field自增并且返回错误
func (*Redis) SetNxWithErr ¶
SetNxWithErr 设置redis的string 如果键已存在
func (*Redis) SetWithErr ¶
SetWithErr ...
func (*Redis) ZRemRangeByRank ¶
ZRemRangeByRank 移除有序集合中给定的排名区间的所有成员
func (*Redis) ZRevRangeByScore ¶
ZRevRangeByScore ...
func (*Redis) ZRevRangeByScoreWithScores ¶
ZRevRangeByScoreWithScores ...
func (*Redis) ZRevRangeWithScores ¶
ZRevRangeWithScores ...
Click to show internal directories.
Click to hide internal directories.