goredis

package
v1.2.65 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

go-redis

redis 连接和操作 基于 github.com/go-redis/redis 库

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(configs ...Config) (err error)

可以一次初始化多个Redis实例或者 多次调用初始化多个实例

Types

type ClusterConf added in v1.2.56

type ClusterConf []Config

func (ClusterConf) GetCacheConf added in v1.2.56

func (c ClusterConf) GetCacheConf() cache.CacheConf

兼容go-zore

type Config

type Config struct {
	Name     string `yaml:"Name" json:"name,optional"`
	Addr     string `yaml:"Addr" json:"addr,optional"`
	Password string `yaml:"Password" json:"password,optional"`
	DB       int    `yaml:"DB" json:"db,optional"`
	Prefix   string `yaml:"Prefix" json:"prefix,optional"`
	AutoPing bool   `yaml:"AutoPing" json:"autoPing,optional"`
	TLS      bool   `yaml:"TLS" json:"tls,optional"`

	Type   string `yaml:"Type" json:",default=node,options=node|cluster"`
	Weight int    `yaml:"Weight" json:",default=100"` //for gozero
}

type GoRedis

type GoRedis struct {
	Redis  *redis.Client
	Config Config
	Ctx    context.Context
}

func Default

func Default() *GoRedis

func GetClient

func GetClient(names ...string) *GoRedis

func New

func New(conf Config) (cli *GoRedis, err error)

func (*GoRedis) BLPop added in v1.2.56

func (s *GoRedis) BLPop(timeout time.Duration, key string) *redis.StringSliceCmd

Blpop uses passed in redis connection to execute blocking queries. Doesn't benefit from pooling redis connections of blocking queries

func (*GoRedis) BitCount added in v1.2.56

func (s *GoRedis) BitCount(key string, start, end int64) *redis.IntCmd

BitCount is redis bitcount command implementation.

func (*GoRedis) BitOpAnd added in v1.2.56

func (s *GoRedis) BitOpAnd(destKey string, keys ...string) *redis.IntCmd

BitOpAnd is redis bit operation (and) command implementation.

func (*GoRedis) BitOpNot added in v1.2.56

func (s *GoRedis) BitOpNot(destKey, key string) *redis.IntCmd

BitOpNot is redis bit operation (not) command implementation.

func (*GoRedis) BitOpOr added in v1.2.56

func (s *GoRedis) BitOpOr(destKey string, keys ...string) *redis.IntCmd

BitOpOr is redis bit operation (or) command implementation.

func (*GoRedis) BitOpXor added in v1.2.56

func (s *GoRedis) BitOpXor(destKey string, keys ...string) *redis.IntCmd

BitOpXor is redis bit operation (xor) command implementation.

func (*GoRedis) BitPos added in v1.2.56

func (s *GoRedis) BitPos(key string, bit, start, end int64) *redis.IntCmd

BitPos is redis bitpos command implementation.

func (*GoRedis) Del added in v1.2.56

func (s *GoRedis) Del(keys ...string) *redis.IntCmd

Del deletes keys.

func (*GoRedis) Eval added in v1.2.56

func (s *GoRedis) Eval(script string, keys []string, args ...interface{}) *redis.Cmd

Eval is the implementation of redis eval command.

func (*GoRedis) EvalSha added in v1.2.56

func (s *GoRedis) EvalSha(sha string, keys []string, args ...interface{}) *redis.Cmd

EvalSha is the implementation of redis evalsha command.

func (*GoRedis) Exists added in v1.2.56

func (s *GoRedis) Exists(key string) *redis.IntCmd

Exists is the implementation of redis exists command.

func (*GoRedis) Expire added in v1.2.56

func (s *GoRedis) Expire(key string, seconds int) *redis.BoolCmd

Expire is the implementation of redis expire command.

func (*GoRedis) ExpireAt added in v1.2.56

func (s *GoRedis) ExpireAt(key string, time time.Time) *redis.BoolCmd

Expireat is the implementation of redis expireat command.

func (*GoRedis) GeoAdd added in v1.2.56

func (s *GoRedis) GeoAdd(key string, geoLocation ...*redis.GeoLocation) *redis.IntCmd

GeoAdd is the implementation of redis geoadd command.

func (*GoRedis) GeoDist added in v1.2.56

func (s *GoRedis) GeoDist(key, member1, member2, unit string) *redis.FloatCmd

GeoDist is the implementation of redis geodist command.

func (*GoRedis) GeoHash added in v1.2.56

func (s *GoRedis) GeoHash(key string, members ...string) *redis.StringSliceCmd

GeoHash is the implementation of redis geohash command.

func (*GoRedis) GeoPos added in v1.2.56

func (s *GoRedis) GeoPos(key string, members ...string) *redis.GeoPosCmd

GeoPos is the implementation of redis geopos command.

func (*GoRedis) GeoRadius added in v1.2.56

func (s *GoRedis) GeoRadius(key string, longitude, latitude float64, query *redis.GeoRadiusQuery) *redis.GeoLocationCmd

GeoRadius is the implementation of redis georadius command.

func (*GoRedis) GeoRadiusByMember added in v1.2.56

func (s *GoRedis) GeoRadiusByMember(key, member string, query *redis.GeoRadiusQuery) *redis.GeoLocationCmd

GeoRadiusByMember is the implementation of redis georadiusbymember command.

func (*GoRedis) Get added in v1.2.56

func (s *GoRedis) Get(key string) *redis.StringCmd

Get is the implementation of redis get command.

func (*GoRedis) GetBit added in v1.2.56

func (s *GoRedis) GetBit(key string, offset int64) *redis.IntCmd

GetBit is the implementation of redis getbit command.

func (*GoRedis) HDel added in v1.2.56

func (s *GoRedis) HDel(key string, fields ...string) *redis.IntCmd

Hdel is the implementation of redis hdel command.

func (*GoRedis) HExists added in v1.2.56

func (s *GoRedis) HExists(key, field string) *redis.BoolCmd

Hexists is the implementation of redis hexists command.

func (*GoRedis) HGet added in v1.2.56

func (s *GoRedis) HGet(key, field string) *redis.StringCmd

Hget is the implementation of redis hget command.

func (*GoRedis) HGetAll added in v1.2.56

func (s *GoRedis) HGetAll(key string) *redis.MapStringStringCmd

Hgetall is the implementation of redis hgetall command.

func (*GoRedis) HIncrBy added in v1.2.56

func (s *GoRedis) HIncrBy(key, field string, increment int64) *redis.IntCmd

Hincrby is the implementation of redis hincrby command.

func (*GoRedis) HKeys added in v1.2.56

func (s *GoRedis) HKeys(key string) *redis.StringSliceCmd

Hkeys is the implementation of redis hkeys command.

func (*GoRedis) HLen added in v1.2.56

func (s *GoRedis) HLen(key string) *redis.IntCmd

Hlen is the implementation of redis hlen command.

func (*GoRedis) HMGet added in v1.2.56

func (s *GoRedis) HMGet(key string, fields ...string) *redis.SliceCmd

Hmget is the implementation of redis hmget command.

func (*GoRedis) HMSet added in v1.2.56

func (s *GoRedis) HMSet(key string, fieldsAndValues map[string]string) *redis.BoolCmd

Hmset is the implementation of redis hmset command.

func (*GoRedis) HScan added in v1.2.56

func (s *GoRedis) HScan(key string, cursor uint64, match string, count int64) *redis.ScanCmd

Hscan is the implementation of redis hscan command.

func (*GoRedis) HSet added in v1.2.56

func (s *GoRedis) HSet(key, field, value string) *redis.IntCmd

Hset is the implementation of redis hset command.

func (*GoRedis) HSetNX added in v1.2.56

func (s *GoRedis) HSetNX(key, field, value string) *redis.BoolCmd

Hsetnx is the implementation of redis hsetnx command.

func (*GoRedis) HVals added in v1.2.56

func (s *GoRedis) HVals(key string) *redis.StringSliceCmd

Hvals is the implementation of redis hvals command.

func (*GoRedis) Incr added in v1.2.56

func (s *GoRedis) Incr(key string) *redis.IntCmd

Incr is the implementation of redis incr command.

func (*GoRedis) IncrBy added in v1.2.56

func (s *GoRedis) IncrBy(key string, increment int64) *redis.IntCmd

Incrby is the implementation of redis incrby command.

func (*GoRedis) Keys added in v1.2.56

func (s *GoRedis) Keys(pattern string) *redis.StringSliceCmd

Keys is the implementation of redis keys command.

func (*GoRedis) LLen added in v1.2.56

func (s *GoRedis) LLen(key string) *redis.IntCmd

Llen is the implementation of redis llen command.

func (*GoRedis) LPop added in v1.2.56

func (s *GoRedis) LPop(key string) *redis.StringCmd

Lpop is the implementation of redis lpop command.

func (*GoRedis) LPush added in v1.2.56

func (s *GoRedis) LPush(key string, values ...interface{}) *redis.IntCmd

Lpush is the implementation of redis lpush command.

func (*GoRedis) LRange added in v1.2.56

func (s *GoRedis) LRange(key string, start, stop int64) *redis.StringSliceCmd

Lrange is the implementation of redis lrange command.

func (*GoRedis) LRem added in v1.2.56

func (s *GoRedis) LRem(key string, count int64, value string) *redis.IntCmd

Lrem is the implementation of redis lrem command.

func (*GoRedis) MGet added in v1.2.56

func (s *GoRedis) MGet(keys ...string) *redis.SliceCmd

Mget is the implementation of redis mget command.

func (*GoRedis) PFAdd added in v1.2.56

func (s *GoRedis) PFAdd(key string, values ...interface{}) *redis.IntCmd

Pfadd is the implementation of redis pfadd command.

func (*GoRedis) PFCount added in v1.2.56

func (s *GoRedis) PFCount(key string) *redis.IntCmd

Pfcount is the implementation of redis pfcount command.

func (*GoRedis) PFMerge added in v1.2.56

func (s *GoRedis) PFMerge(dest string, keys ...string) *redis.StatusCmd

Pfmerge is the implementation of redis pfmerge command.

func (*GoRedis) Persist added in v1.2.56

func (s *GoRedis) Persist(key string) *redis.BoolCmd

Persist is the implementation of redis persist command.

func (*GoRedis) Ping added in v1.2.56

func (s *GoRedis) Ping() *redis.StatusCmd

Ping is the implementation of redis ping command.

func (*GoRedis) Pipelined added in v1.2.56

func (s *GoRedis) Pipelined(fn func(redis.Pipeliner) error) ([]redis.Cmder, error)

Pipelined lets fn to execute pipelined commands. fn key must call GetKey or GetKeys to add prefix.

func (*GoRedis) RPop added in v1.2.56

func (s *GoRedis) RPop(key string) *redis.StringCmd

Rpop is the implementation of redis rpop command.

func (*GoRedis) RPush added in v1.2.56

func (s *GoRedis) RPush(key string, values ...interface{}) *redis.IntCmd

Rpush is the implementation of redis rpush command.

func (*GoRedis) SAdd added in v1.2.56

func (s *GoRedis) SAdd(key string, values ...interface{}) *redis.IntCmd

Sadd is the implementation of redis sadd command.

func (*GoRedis) SCard added in v1.2.56

func (s *GoRedis) SCard(key string) *redis.IntCmd

Scard is the implementation of redis scard command.

func (*GoRedis) SDiff added in v1.2.56

func (s *GoRedis) SDiff(keys ...string) *redis.StringSliceCmd

Sdiff is the implementation of redis sdiff command.

func (*GoRedis) SDiffStore added in v1.2.56

func (s *GoRedis) SDiffStore(destination string, keys ...string) *redis.IntCmd

Sdiffstore is the implementation of redis sdiffstore command.

func (*GoRedis) SInter added in v1.2.56

func (s *GoRedis) SInter(keys ...string) *redis.StringSliceCmd

Sinter is the implementation of redis sinter command.

func (*GoRedis) SInterStore added in v1.2.56

func (s *GoRedis) SInterStore(destination string, keys ...string) *redis.IntCmd

Sinterstore is the implementation of redis sinterstore command.

func (*GoRedis) SIsMember added in v1.2.56

func (s *GoRedis) SIsMember(key string, value interface{}) *redis.BoolCmd

Sismember is the implementation of redis sismember command.

func (*GoRedis) SMembers added in v1.2.56

func (s *GoRedis) SMembers(key string) *redis.StringSliceCmd

Smembers is the implementation of redis smembers command.

func (*GoRedis) SPop added in v1.2.56

func (s *GoRedis) SPop(key string) *redis.StringCmd

Spop is the implementation of redis spop command.

func (*GoRedis) SRandMember added in v1.2.56

func (s *GoRedis) SRandMember(key string) *redis.StringCmd

Srandmember is the implementation of redis srandmember command.

func (*GoRedis) SRem added in v1.2.56

func (s *GoRedis) SRem(key string, values ...interface{}) *redis.IntCmd

Srem is the implementation of redis srem command.

func (*GoRedis) SScan added in v1.2.56

func (s *GoRedis) SScan(key string, cursor uint64, match string, count int64) *redis.ScanCmd

Sscan is the implementation of redis sscan command.

func (*GoRedis) SUnion added in v1.2.56

func (s *GoRedis) SUnion(keys ...string) *redis.StringSliceCmd

Sunion is the implementation of redis sunion command.

func (*GoRedis) SUnionStore added in v1.2.56

func (s *GoRedis) SUnionStore(destination string, keys ...string) *redis.IntCmd

Sunionstore is the implementation of redis sunionstore command.

func (*GoRedis) Scan added in v1.2.56

func (s *GoRedis) Scan(cursor uint64, match string, count int64) *redis.ScanCmd

Scan is the implementation of redis scan command.

func (*GoRedis) ScriptLoad added in v1.2.56

func (s *GoRedis) ScriptLoad(script string) *redis.StringCmd

ScriptLoad is the implementation of redis script load command.

func (*GoRedis) Set added in v1.2.56

func (s *GoRedis) Set(key, value string) *redis.StatusCmd

Set is the implementation of redis set command.

func (*GoRedis) SetBit added in v1.2.56

func (s *GoRedis) SetBit(key string, offset int64, value int) *redis.IntCmd

SetBit is the implementation of redis setbit command.

func (*GoRedis) SetEx added in v1.2.56

func (s *GoRedis) SetEx(key, value string, expiration time.Duration) *redis.StatusCmd

Setex is the implementation of redis setex command.

func (*GoRedis) String added in v1.2.56

func (s *GoRedis) String() string

String returns the string representation of s.

func (*GoRedis) TTL added in v1.2.56

func (s *GoRedis) TTL(key string) *redis.DurationCmd

Ttl is the implementation of redis ttl command.

func (*GoRedis) WrapKey added in v1.2.56

func (s *GoRedis) WrapKey(key string) string

func (*GoRedis) WrapKeys added in v1.2.56

func (s *GoRedis) WrapKeys(keys ...string) []string

func (*GoRedis) ZAdd added in v1.2.56

func (s *GoRedis) ZAdd(key string, value ...redis.Z) *redis.IntCmd

Zadd is the implementation of redis zadd command.

func (*GoRedis) ZCard added in v1.2.56

func (s *GoRedis) ZCard(key string) *redis.IntCmd

Zcard is the implementation of redis zcard command.

func (*GoRedis) ZCount added in v1.2.56

func (s *GoRedis) ZCount(key string, max, min string) *redis.IntCmd

Zcount is the implementation of redis zcount command.

func (*GoRedis) ZIncrBy added in v1.2.56

func (s *GoRedis) ZIncrBy(key string, increment float64, field string) *redis.FloatCmd

Zincrby is the implementation of redis zincrby command.

func (*GoRedis) ZRangeByScoreWithScores added in v1.2.56

func (s *GoRedis) ZRangeByScoreWithScores(key string, opt *redis.ZRangeBy) *redis.ZSliceCmd

ZrangebyscoreWithScores is the implementation of redis zrangebyscore command with scores.

func (*GoRedis) ZRangeWithScores added in v1.2.56

func (s *GoRedis) ZRangeWithScores(key string, start, stop int64) *redis.ZSliceCmd

ZrangeWithScores is the implementation of redis zrange command with scores.

func (*GoRedis) ZRank added in v1.2.56

func (s *GoRedis) ZRank(key, field string) *redis.IntCmd

Zrank is the implementation of redis zrank command.

func (*GoRedis) ZRemRangeByScore added in v1.2.56

func (s *GoRedis) ZRemRangeByScore(key string, max, min string) *redis.IntCmd

Zremrangebyscore is the implementation of redis zremrangebyscore command.

func (*GoRedis) ZRevRangeByScoreWithScores added in v1.2.56

func (s *GoRedis) ZRevRangeByScoreWithScores(key string, opt *redis.ZRangeBy) *redis.ZSliceCmd

ZrevrangebyscoreWithScores is the implementation of redis zrevrangebyscore command with scores.

func (*GoRedis) ZRevRangeWithScores added in v1.2.56

func (s *GoRedis) ZRevRangeWithScores(key string, start, stop int64) *redis.ZSliceCmd

ZRevRangeWithScores is the implementation of redis zrevrange command with scores.

func (*GoRedis) ZRevRank added in v1.2.56

func (s *GoRedis) ZRevRank(key, field string) *redis.IntCmd

Zrevrank is the implementation of redis zrevrank command.

func (*GoRedis) ZScore added in v1.2.56

func (s *GoRedis) ZScore(key, value string) *redis.FloatCmd

Zscore is the implementation of redis zscore command.

func (*GoRedis) ZUnionStore added in v1.2.56

func (s *GoRedis) ZUnionStore(dest string, store *redis.ZStore) *redis.IntCmd

Zunionstore is the implementation of redis zunionstore command.

func (*GoRedis) Zrange added in v1.2.56

func (s *GoRedis) Zrange(key string, start, stop int64) *redis.StringSliceCmd

Zrange is the implementation of redis zrange command.

func (*GoRedis) Zrem added in v1.2.56

func (s *GoRedis) Zrem(key string, values ...interface{}) *redis.IntCmd

Zrem is the implementation of redis zrem command.

func (*GoRedis) Zremrangebyrank added in v1.2.56

func (s *GoRedis) Zremrangebyrank(key string, start, stop int64) *redis.IntCmd

Zremrangebyrank is the implementation of redis zremrangebyrank command.

func (*GoRedis) Zrevrange added in v1.2.56

func (s *GoRedis) Zrevrange(key string, start, stop int64) *redis.StringSliceCmd

Zrevrange is the implementation of redis zrevrange command.

type RedisHook added in v1.2.56

type RedisHook struct {
	Prefix string `yaml:"Prefix" json:"prefix,optional"`
}

func (*RedisHook) DialHook added in v1.2.56

func (s *RedisHook) DialHook(next redis0.DialHook) redis0.DialHook

func (*RedisHook) ProcessHook added in v1.2.56

func (s *RedisHook) ProcessHook(next redis0.ProcessHook) redis0.ProcessHook

func (*RedisHook) ProcessPipelineHook added in v1.2.56

func (s *RedisHook) ProcessPipelineHook(next redis0.ProcessPipelineHook) redis0.ProcessPipelineHook

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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