Documentation ¶
Overview ¶
trace redis link: https://github.com/smacker/opentracing-go-redis
Index ¶
Constants ¶
View Source
const ( // PrefixCheckRepeat check repeat key PrefixCheckRepeat = "CHECK_REPEAT" // RepeatDefaultTimeout define default timeout RepeatDefaultTimeout = 60 )
View Source
const ( // LockKey redis lock key LockKey = "snake:redis:lock:%s" // DefaultTimeout default expire time DefaultTimeout = 2 * time.Second )
View Source
const ErrRedisNotFound = redis.Nil
ErrRedisNotFound not exist in redis
Variables ¶
View Source
var RedisClient *redis.Client
RedisClient redis 客户端
Functions ¶
func WrapRedisClient ¶ added in v1.3.1
WrapRedisClient adds opentracing measurements for commands and returns cloned client
Types ¶
type CheckRepeat ¶ added in v1.3.0
type CheckRepeat interface { Set(key string, value interface{}, expiration time.Duration) error Get(key string) (string, error) SetNX(key string, value interface{}, expiration time.Duration) (bool, error) Del(keys string) int64 }
CheckRepeat define interface
func NewCheckRepeat ¶ added in v1.3.0
func NewCheckRepeat(client *redis.Client) CheckRepeat
NewCheckRepeat create a check repeat
type Config ¶ added in v1.3.1
type Config struct { Addr string Password string DB int MinIdleConn int DialTimeout time.Duration ReadTimeout time.Duration WriteTimeout time.Duration PoolSize int PoolTimeout time.Duration }
Config redis config
type IDAlloc ¶ added in v1.3.0
type IDAlloc struct {
// contains filtered or unexported fields
}
IDAlloc id生成器 key 为业务key, 由业务前缀+功能前缀+具体场景id组成 比如生成用户id, 可以传入user_id, 完整示例: snake:idalloc:user_id
func NewIDAlloc ¶ added in v1.3.0
func NewIDAlloc(conn *redis.Client) *IDAlloc
NewIDAlloc create a id alloc instance
func (*IDAlloc) GetCurrentID ¶ added in v1.3.0
GetCurrentID 获取当前id
Click to show internal directories.
Click to hide internal directories.