Documentation
¶
Index ¶
- Constants
- Variables
- func Bytes2String(b []byte) string
- func IsNil(err error) bool
- func KeyHash(key interface{}) uint32
- func Put(key string, opts ...Option)
- func SetErrorLog(l ErrLog)
- func String2Bytes(s string) []byte
- func WriteLog(err error, cmd string, opt *Option)
- type CacheHandler
- type ConfigParam
- func (p ConfigParam) Clone() ConfigParam
- func (p ConfigParam) Exists(key string) bool
- func (p ConfigParam) Get(key string) string
- func (p ConfigParam) ToBool(key string) bool
- func (p ConfigParam) ToFloat64(key string) float64
- func (p ConfigParam) ToInt(key string) int
- func (p ConfigParam) ToInt64(key string) int64
- func (p ConfigParam) ToUint8(key string) uint8
- type ErrLog
- type Key
- type Option
- func (o *Option) Addr() string
- func (o *Option) ConnMaxIdleTime() time.Duration
- func (o *Option) ConnMaxLifetime() time.Duration
- func (o *Option) DialTimeout() time.Duration
- func (o *Option) Id() string
- func (o *Option) NewClient() *redis.Client
- func (o *Option) PoolWaitTimeout() time.Duration
- func (o *Option) ReadTimeout() time.Duration
- func (o *Option) ToOptions() *redis.Options
- func (o *Option) WriteTimeout() time.Duration
- type Pool
- func (p *Pool) Acquire(ctx context.Context, key string, lockSeconds int64) (token int64, err error)
- func (p *Pool) AcquireByIncr(ctx context.Context, key string, acqNum, limitNum int64, keyTimeoutSecond int) (ok bool, err error)
- func (p *Pool) AcquireByLeakyBucket(ctx context.Context, key string, current int64, ...) (ok bool, err error)
- func (p *Pool) BitCount(ctx context.Context, key string, bitCount *redis.BitCount) (num int64, err error)
- func (p *Pool) BitField(ctx context.Context, key string, values ...any) (res []int64, err error)
- func (p *Pool) BitOpAnd(ctx context.Context, destKey string, keys ...string) (bytesLen int64, err error)
- func (p *Pool) BitOpNot(ctx context.Context, destKey string, key string) (bytesLen int64, err error)
- func (p *Pool) BitOpOr(ctx context.Context, destKey string, keys ...string) (bytesLen int64, err error)
- func (p *Pool) BitOpXor(ctx context.Context, destKey string, keys ...string) (bytesLen int64, err error)
- func (p *Pool) ComCache(ctx context.Context, key string, timeoutSeconds int64, handler CacheHandler) (*proto2.CacheItem, error)
- func (p *Pool) ConfigGet(ctx context.Context, parameter string) (res ConfigParam, err error)
- func (p *Pool) ConfigSet(ctx context.Context, parameter, value string) (ok bool, err error)
- func (p *Pool) Del(ctx context.Context, keys ...string) (delNum int64, err error)
- func (p *Pool) Exists(ctx context.Context, keys ...string) (existsNum int64, err error)
- func (p *Pool) Expire(ctx context.Context, key string, timeout time.Duration) (ok bool, err error)
- func (p *Pool) ExpireAt(ctx context.Context, key string, tm time.Time) (exists bool, err error)
- func (p *Pool) GeoAdd(ctx context.Context, key string, geoLocations ...*redis.GeoLocation) (newCount int64, err error)
- func (p *Pool) GeoDist(ctx context.Context, key string, member1, member2, unit string) (float64, error)
- func (p *Pool) GeoPos(ctx context.Context, key string, members ...string) ([]*redis.GeoPos, error)
- func (p *Pool) GeoRadius(ctx context.Context, key string, longitude, latitude float64, ...) ([]redis.GeoLocation, error)
- func (p *Pool) GeoSearch(ctx context.Context, key string, q *redis.GeoSearchQuery) ([]string, error)
- func (p *Pool) Get(ctx context.Context, key string) (value string, err error)
- func (p *Pool) GetBit(ctx context.Context, key string, offset int64) (value int64, err error)
- func (p *Pool) GetBytes(ctx context.Context, key string) (value []byte, err error)
- func (p *Pool) HDel(ctx context.Context, key string, fields ...string) (delNum int64, err error)
- func (p *Pool) HExists(ctx context.Context, key string, field string) (exists bool, err error)
- func (p *Pool) HGet(ctx context.Context, key, field string) (value string, err error)
- func (p *Pool) HGetAll(ctx context.Context, key string) (value map[string]string, err error)
- func (p *Pool) HGetBytes(ctx context.Context, key, field string) (value []byte, err error)
- func (p *Pool) HIncrBy(ctx context.Context, key, field string, incr int64) (value int64, err error)
- func (p *Pool) HIncrByFloat(ctx context.Context, key, field string, incr float64) (value float64, err error)
- func (p *Pool) HMGet(ctx context.Context, key string, fields ...string) (values []string, err error)
- func (p *Pool) HMGetMap(ctx context.Context, key string, fields ...string) (valMap map[string]string, err error)
- func (p *Pool) HMSet(ctx context.Context, key string, values ...any) (ok bool, err error)
- func (p *Pool) HScan(ctx context.Context, key string, cursor uint64, match string, count int64) (keys []string, newCursor uint64, err error)
- func (p *Pool) HSet(ctx context.Context, key, field string, value any) (isNew int64, err error)
- func (p *Pool) HSetMap(ctx context.Context, key string, fv map[string]any) (value bool, err error)
- func (p *Pool) HSetNX(ctx context.Context, key, field string, value any) (ok bool, err error)
- func (p *Pool) HasLock(ctx context.Context, key string) (hasLock bool, err error)
- func (p *Pool) IncrBy(ctx context.Context, key string, value int64) (newValue int64, err error)
- func (p *Pool) IncrByFloat(ctx context.Context, key string, value float64) (newValue float64, err error)
- func (p *Pool) Info(ctx context.Context, sections ...string) (info string, err error)
- func (p *Pool) InfoMap(ctx context.Context, sections ...string) (info map[string]map[string]string, err error)
- func (p *Pool) LLen(ctx context.Context, key string) (length int64, err error)
- func (p *Pool) LPop(ctx context.Context, key string) (value string, err error)
- func (p *Pool) LPush(ctx context.Context, key string, values ...any) (length int64, err error)
- func (p *Pool) LRange(ctx context.Context, key string, start, stop int64) (items []string, err error)
- func (p *Pool) LRem(ctx context.Context, key string, count int64, val any) (items int64, err error)
- func (p *Pool) MGet(ctx context.Context, keys ...string) (values []string, err error)
- func (p *Pool) MGetBytes(ctx context.Context, keys ...string) (values [][]byte, err error)
- func (p *Pool) MSet(ctx context.Context, values ...any) (ok bool, err error)
- func (p *Pool) Option() *Option
- func (p *Pool) RPop(ctx context.Context, key string) (value string, err error)
- func (p *Pool) RPopLPush(ctx context.Context, srcKey, dstKey string) (value string, err error)
- func (p *Pool) RPush(ctx context.Context, key string, values ...any) (length int64, err error)
- func (p *Pool) Release(ctx context.Context, key string, token int64) (delNum int64, err error)
- func (p *Pool) RunScript(ctx context.Context, script *redis.Script, keys []string, args ...any) (res any, err error)
- func (p *Pool) SAdd(ctx context.Context, key string, members ...any) (newNum int64, err error)
- func (p *Pool) SCard(ctx context.Context, key string) (length int64, err error)
- func (p *Pool) SIsMember(ctx context.Context, key string, member any) (exists bool, err error)
- func (p *Pool) SMembers(ctx context.Context, key string) (list []string, err error)
- func (p *Pool) SPop(ctx context.Context, key string) (member string, err error)
- func (p *Pool) SPopN(ctx context.Context, key string, count int64) (members []string, err error)
- func (p *Pool) SRem(ctx context.Context, key string, members ...any) (delNum int64, err error)
- func (p *Pool) SScan(ctx context.Context, key string, cursor uint64, match string, count int64) (keys []string, newCursor uint64, err error)
- func (p *Pool) Scan(ctx context.Context, cursor uint64, match string, count int64) (keys []string, newCursor uint64, err error)
- func (p *Pool) Set(ctx context.Context, key string, value any, expiration time.Duration) (ok bool, err error)
- func (p *Pool) SetBit(ctx context.Context, key string, offset int64, value int64) (oldValue int64, err error)
- func (p *Pool) SetEx(ctx context.Context, key string, value any, timeout time.Duration) (ok bool, err error)
- func (p *Pool) SetNx(ctx context.Context, key string, value any, timeout time.Duration) (ok bool, err error)
- func (p *Pool) Ttl(ctx context.Context, key string) (duration time.Duration, err error)
- func (p *Pool) Type(ctx context.Context, key string) (t string, err error)
- func (p *Pool) ZAdd(ctx context.Context, key string, members ...redis.Z) (newNum int64, err error)
- func (p *Pool) ZCard(ctx context.Context, key string) (length int64, err error)
- func (p *Pool) ZCount(ctx context.Context, key, min, max string) (count int64, err error)
- func (p *Pool) ZIncrBy(ctx context.Context, key string, increment float64, member string) (score float64, err error)
- func (p *Pool) ZRange(ctx context.Context, key string, start, stop int64) (list []string, err error)
- func (p *Pool) ZRangeByScore(ctx context.Context, key string, opt *redis.ZRangeBy) (list []string, err error)
- func (p *Pool) ZRangeByScoreWithScores(ctx context.Context, key string, opt *redis.ZRangeBy) (list []redis.Z, err error)
- func (p *Pool) ZRangeWithScores(ctx context.Context, key string, start, stop int64) (list []redis.Z, err error)
- func (p *Pool) ZRank(ctx context.Context, key, member string) (rank int64, err error)
- func (p *Pool) ZRevRange(ctx context.Context, key string, start, stop int64) (list []string, err error)
- func (p *Pool) ZRevRangeWithScores(ctx context.Context, key string, start, stop int64) (list []redis.Z, err error)
- func (p *Pool) ZRevRank(ctx context.Context, key, member string) (rank int64, err error)
- func (p *Pool) ZScan(ctx context.Context, key string, cursor uint64, match string, count int64) (keys []string, newCursor uint64, err error)
- func (p *Pool) ZScore(ctx context.Context, key, member string) (score float64, err error)
Constants ¶
View Source
const ( OK = `OK` Success = 1 ErrNil = redis.Nil )
Variables ¶
View Source
var ( DefaultOption = func() Option { return Option{ Network: "tcp", Host: "127.0.0.1", Port: 6379, MaxRetries: 3, ContextTimeoutEnabled: true, PoolSize: 16, MinIdleConns: 2, MaxIdleConns: 8, MaxActiveConns: 16, } } JsonOption = func(data []byte) (opt Option, err error) { opt = DefaultOption() err = json.Unmarshal(data, &opt) return } YamlOption = func(data []byte) (opt Option, err error) { opt = DefaultOption() err = yaml.Unmarshal(data, &opt) return } )
View Source
var (
DefaultCacheTimeout = time.Hour * 24
)
View Source
var (
Uint32Hash = crc32.ChecksumIEEE
)
Functions ¶
func SetErrorLog ¶
func SetErrorLog(l ErrLog)
Types ¶
type CacheHandler ¶
type ConfigParam ¶
func (ConfigParam) Clone ¶
func (p ConfigParam) Clone() ConfigParam
func (ConfigParam) ToFloat64 ¶
func (p ConfigParam) ToFloat64(key string) float64
ToFloat64 获取Float64
type Option ¶
type Option struct { Network string `json:"network" yaml:"network"` Host string `json:"host" yaml:"host"` Port uint32 `json:"port" yaml:"port"` Username string `json:"username" yaml:"username"` Password string `json:"password" yaml:"password"` DB uint32 `json:"DB" yaml:"DB"` MaxRetries uint32 `json:"maxRetries" yaml:"maxRetries"` DialTimeoutSecond uint32 `json:"dialTimeoutSecond" yaml:"dialTimeoutSecond"` ReadTimeoutSecond uint32 `json:"readTimeoutSecond" yaml:"readTimeoutSecond"` WriteTimeoutSecond uint32 `json:"writeTimeoutSecond" yaml:"writeTimeoutSecond"` ContextTimeoutEnabled bool `json:"contextTimeoutEnabled" yaml:"contextTimeoutEnabled"` PoolSize uint32 `json:"poolSize" yaml:"poolSize"` PoolWaitTimeoutSecond uint32 `json:"poolWaitTimeoutSecond" yaml:"poolWaitTimeoutSecond"` MinIdleConns uint32 `json:"minIdleConns" yaml:"minIdleConns"` MaxIdleConns uint32 `json:"maxIdleConns" yaml:"maxIdleConns"` MaxActiveConns uint32 `json:"maxActiveConns" yaml:"maxActiveConns"` ConnMaxIdleTimeSecond uint32 `json:"connMaxIdleTimeSecond" yaml:"connMaxIdleTimeSecond"` ConnMaxLifetimeSecond uint32 `json:"connMaxLifetimeSecond" yaml:"connMaxLifetimeSecond"` TLSConfig *tls.Config // contains filtered or unexported fields }
func (*Option) ConnMaxIdleTime ¶
func (*Option) ConnMaxLifetime ¶
func (*Option) DialTimeout ¶
func (*Option) PoolWaitTimeout ¶
func (*Option) ReadTimeout ¶
func (*Option) WriteTimeout ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func GetWithIndex ¶
func GetWithShard ¶
func (*Pool) AcquireByIncr ¶
func (*Pool) AcquireByLeakyBucket ¶
func (*Pool) BitField ¶
BitField is an API after Redis version 3.2 type: 位宽格式:u(无符号)/i(有符号)+ 位数(1-64) u8(8位无符号整数) offset: 位段起始位置(比特偏移量),支持#前缀指定字段序(如#0第1个字段) 0 或 #1 原子增加第2个字段(4位无符号计数器) BITFIELD api_count OVERFLOW SAT INCRBY u4 #1 1 OVERFLOW: WRAP 回绕(默认):溢出时从最小值重新计数 循环计数器(如ID生成) OVERFLOW: SAT 饱和:超出上限取最大值,低于下限取最小值 限制数值范围(如温度值) OVERFLOW: FAIL 失败:溢出时返回 nil,不执行操作 严格数值控制(如余额)
func (*Pool) HIncrByFloat ¶
func (*Pool) IncrByFloat ¶
func (*Pool) ZRangeByScore ¶
func (*Pool) ZRangeByScoreWithScores ¶
func (*Pool) ZRangeWithScores ¶
func (*Pool) ZRevRangeWithScores ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.