Documentation
¶
Index ¶
- Constants
- func InitRedis()
- type ClientType
- type ClusterOptions
- type IRedis
- type RedisClient
- func (client *RedisClient) DecrBy(ctx context.Context, key string, value int64) (int64, error)
- func (client *RedisClient) Del(ctx context.Context, key string) error
- func (client *RedisClient) Eval(ctx context.Context, script string, keys []string, args ...interface{}) *redis.Cmd
- func (client *RedisClient) EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *redis.Cmd
- func (client *RedisClient) ExpireAt(ctx context.Context, key string, expiration time.Duration) error
- func (client *RedisClient) Get(ctx context.Context, key string) (string, error)
- func (client *RedisClient) HGet(ctx context.Context, key string, field string) (string, error)
- func (client *RedisClient) HGetAll(ctx context.Context, key string) (map[string]string, error)
- func (client *RedisClient) HRem(ctx context.Context, key string, fields ...string) error
- func (client *RedisClient) HSet(ctx context.Context, key string, field, value string) error
- func (client *RedisClient) IncrBy(ctx context.Context, key string, value int64) (int64, error)
- func (client *RedisClient) LLen(ctx context.Context, key string) (int64, error)
- func (client *RedisClient) LPush(ctx context.Context, key string, value string) (int64, error)
- func (client *RedisClient) LRem(ctx context.Context, key string, count int64, value string) (int64, error)
- func (client *RedisClient) Lock(ctx context.Context, key string, acquireTimeout time.Duration, ...) error
- func (client *RedisClient) NewScript(src string) *redis.Script
- func (client *RedisClient) Pipeline() redis.Pipeliner
- func (client *RedisClient) ScriptExists(ctx context.Context, hashes ...string) *redis.BoolSliceCmd
- func (client *RedisClient) ScriptLoad(ctx context.Context, script string) *redis.StringCmd
- func (client *RedisClient) Set(ctx context.Context, key, value string, expiration time.Duration) error
- func (client *RedisClient) UnLock(ctx context.Context, key string) error
- func (client *RedisClient) ZAdd(ctx context.Context, key, value string, score float64) error
- func (client *RedisClient) ZCard(ctx context.Context, key string) (int, error)
- func (client *RedisClient) ZCount(ctx context.Context, key string, min, max int64) (int64, error)
- func (client *RedisClient) ZIncrBy(ctx context.Context, key string, increment float64, member string) error
- func (client *RedisClient) ZRange(ctx context.Context, key string, start, stop int64) ([]string, error)
- func (client *RedisClient) ZRangeWithScores(ctx context.Context, key string, start, stop int64) ([]redis.Z, error)
- func (client *RedisClient) ZRem(ctx context.Context, key string, fields ...string) error
- func (client *RedisClient) ZRevRange(ctx context.Context, key string, start, stop int64) ([]string, error)
- func (client *RedisClient) ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) ([]redis.Z, error)
- type RedisCluster
- func (client *RedisCluster) DecrBy(ctx context.Context, key string, value int64) (int64, error)
- func (client *RedisCluster) Del(ctx context.Context, key string) error
- func (client *RedisCluster) Eval(ctx context.Context, script string, keys []string, args ...interface{}) *redis.Cmd
- func (client *RedisCluster) EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *redis.Cmd
- func (client *RedisCluster) ExpireAt(ctx context.Context, key string, expiration time.Duration) error
- func (client *RedisCluster) Get(ctx context.Context, key string) (string, error)
- func (client *RedisCluster) HGet(ctx context.Context, key string, field string) (string, error)
- func (client *RedisCluster) HGetAll(ctx context.Context, key string) (map[string]string, error)
- func (client *RedisCluster) HRem(ctx context.Context, key string, fields ...string) error
- func (client *RedisCluster) HSet(ctx context.Context, key string, field, value string) error
- func (client *RedisCluster) IncrBy(ctx context.Context, key string, value int64) (int64, error)
- func (client *RedisCluster) LLen(ctx context.Context, key string) (int64, error)
- func (client *RedisCluster) LPush(ctx context.Context, key string, value string) (int64, error)
- func (client *RedisCluster) LRem(ctx context.Context, key string, count int64, value string) (int64, error)
- func (client *RedisCluster) Lock(ctx context.Context, key string, acquireTimeOut, lockTimeOut time.Duration) error
- func (client *RedisCluster) NewScript(src string) *redis.Script
- func (client *RedisCluster) Pipeline() redis.Pipeliner
- func (client *RedisCluster) ScriptExists(ctx context.Context, hashes ...string) *redis.BoolSliceCmd
- func (client *RedisCluster) ScriptLoad(ctx context.Context, script string) *redis.StringCmd
- func (client *RedisCluster) Set(ctx context.Context, key, value string, expiration time.Duration) error
- func (client *RedisCluster) UnLock(ctx context.Context, key string) error
- func (client *RedisCluster) ZAdd(ctx context.Context, key, value string, score float64) error
- func (client *RedisCluster) ZCard(ctx context.Context, key string) (int, error)
- func (client *RedisCluster) ZCount(ctx context.Context, key string, min, max int64) (int64, error)
- func (client *RedisCluster) ZIncrBy(ctx context.Context, key string, increment float64, member string) error
- func (client *RedisCluster) ZRange(ctx context.Context, key string, start, stop int64) ([]string, error)
- func (client *RedisCluster) ZRangeWithScores(ctx context.Context, key string, start, stop int64) ([]redis.Z, error)
- func (client *RedisCluster) ZRem(ctx context.Context, key string, fields ...string) error
- func (client *RedisCluster) ZRevRange(ctx context.Context, key string, start, stop int64) ([]string, error)
- func (client *RedisCluster) ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) ([]redis.Z, error)
Constants ¶
View Source
const (
DEFAULT_LOCK_TOKEN = "Matrix"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClientType ¶
type ClientType int32
const ( T_Client ClientType = 1 T_Cluster ClientType = 2 NilError = redis.Nil )
type ClusterOptions ¶
type ClusterOptions func(*redis.ClusterOptions)
type IRedis ¶
type IRedis interface { Get(ctx context.Context, key string) (string, error) Set(ctx context.Context, key, value string, expiration time.Duration) error HSet(ctx context.Context, key string, field, value string) error HGet(ctx context.Context, key string, field string) (string, error) HGetAll(ctx context.Context, key string) (map[string]string, error) HRem(ctx context.Context, key string, fields ...string) error ZAdd(ctx context.Context, key, value string, score float64) error ZRange(ctx context.Context, key string, start, stop int64) ([]string, error) ZRem(ctx context.Context, key string, fields ...string) error ZRevRange(ctx context.Context, key string, start, stop int64) ([]string, error) ZCard(ctx context.Context, key string) (int, error) ZIncrBy(ctx context.Context, key string, increment float64, member string) error ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) ([]redis.Z, error) ZRangeWithScores(ctx context.Context, key string, start, stop int64) ([]redis.Z, error) ZCount(ctx context.Context, key string, min, max int64) (int64, error) LPush(ctx context.Context, key string, value string) (int64, error) LRem(ctx context.Context, key string, count int64, value string) (int64, error) LLen(ctx context.Context, key string) (int64, error) Del(ctx context.Context, key string) error ExpireAt(ctx context.Context, key string, expiration time.Duration) error Lock(ctx context.Context, key string, acquireTimeout time.Duration, lockTimeout time.Duration) error UnLock(ctx context.Context, key string) error IncrBy(ctx context.Context, key string, value int64) (int64, error) DecrBy(ctx context.Context, key string, value int64) (int64, error) Pipeline() redis.Pipeliner Eval(ctx context.Context, script string, keys []string, args ...interface{}) *redis.Cmd EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *redis.Cmd ScriptExists(ctx context.Context, hashes ...string) *redis.BoolSliceCmd ScriptLoad(ctx context.Context, script string) *redis.StringCmd NewScript(src string) *redis.Script }
var (
RedisGlobal IRedis
)
func NewRedisClient ¶
func NewRedisClient(addr, userName, userPwd string, clientType ClientType) IRedis
type RedisClient ¶
type RedisClient struct {
Client *redis.Client
}
func (*RedisClient) Eval ¶
func (client *RedisClient) Eval(ctx context.Context, script string, keys []string, args ...interface{}) *redis.Cmd
func (*RedisClient) EvalSha ¶
func (client *RedisClient) EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *redis.Cmd
func (*RedisClient) NewScript ¶
func (client *RedisClient) NewScript(src string) *redis.Script
func (*RedisClient) Pipeline ¶
func (client *RedisClient) Pipeline() redis.Pipeliner
func (*RedisClient) ScriptExists ¶
func (client *RedisClient) ScriptExists(ctx context.Context, hashes ...string) *redis.BoolSliceCmd
func (*RedisClient) ScriptLoad ¶
func (client *RedisClient) ScriptLoad(ctx context.Context, script string) *redis.StringCmd
func (*RedisClient) UnLock ¶
func (client *RedisClient) UnLock(ctx context.Context, key string) error
func (*RedisClient) ZRangeWithScores ¶
func (*RedisClient) ZRevRangeWithScores ¶
type RedisCluster ¶
type RedisCluster struct { Client *redis.ClusterClient // contains filtered or unexported fields }
func (*RedisCluster) Eval ¶
func (client *RedisCluster) Eval(ctx context.Context, script string, keys []string, args ...interface{}) *redis.Cmd
func (*RedisCluster) EvalSha ¶
func (client *RedisCluster) EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *redis.Cmd
func (*RedisCluster) Lock ¶
func (client *RedisCluster) Lock(ctx context.Context, key string, acquireTimeOut, lockTimeOut time.Duration) error
Lock @Description: redis distributed lock @param key mutex name @param ttl set the expiry of a mutex to the given value. @param retryDelay set the amount of time to wait between retries. @param tries set the number of times lock acquire is attempted @return error
func (*RedisCluster) NewScript ¶
func (client *RedisCluster) NewScript(src string) *redis.Script
func (*RedisCluster) Pipeline ¶
func (client *RedisCluster) Pipeline() redis.Pipeliner
func (*RedisCluster) ScriptExists ¶
func (client *RedisCluster) ScriptExists(ctx context.Context, hashes ...string) *redis.BoolSliceCmd
func (*RedisCluster) ScriptLoad ¶
func (client *RedisCluster) ScriptLoad(ctx context.Context, script string) *redis.StringCmd
func (*RedisCluster) UnLock ¶
func (client *RedisCluster) UnLock(ctx context.Context, key string) error
func (*RedisCluster) ZRangeWithScores ¶
func (*RedisCluster) ZRevRangeWithScores ¶
Click to show internal directories.
Click to hide internal directories.