Documentation ¶
Index ¶
Constants ¶
View Source
const ( // PrefixCheckRepeat check repeat key PrefixCheckRepeat = "CHECK_REPEAT" // RepeatDefaultTimeout define default timeout RepeatDefaultTimeout = 60 )
View Source
const ( // ErrRedisNotFound not exist in redis ErrRedisNotFound = redis.Nil // DefaultRedisName default redis name DefaultRedisName = "default" )
Variables ¶
View Source
var RedisClient *redis.Client
RedisClient redis 客户端
Functions ¶
Types ¶
type CheckRepeat ¶
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 ¶
func NewCheckRepeat(client *redis.Client) CheckRepeat
NewCheckRepeat create a check repeat
type Config ¶
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 // tracing switch EnableTrace bool }
Config redis config
type IDAlloc ¶
type IDAlloc struct {
// contains filtered or unexported fields
}
IDAlloc id生成器 key 为业务key, 由业务前缀+功能前缀+具体场景id组成 比如生成用户id, 可以传入user_id, 完整示例: eagle:idalloc:user_id
func NewIDAlloc ¶
func NewIDAlloc(conn *redis.Client) *IDAlloc
NewIDAlloc create a id alloc instance
func (*IDAlloc) GetCurrentID ¶
GetCurrentID 获取当前id
type RedisManager ¶
RedisManager define a redis manager nolint
func (*RedisManager) GetClient ¶
func (r *RedisManager) GetClient(name string) (*redis.Client, error)
GetClient get a redis instance
Click to show internal directories.
Click to hide internal directories.