Documentation
¶
Index ¶
- Variables
- func Client() *rkv
- func Close() error
- func Init(id string, opts ...func(o *Options)) error
- func NewClient(id string, opts ...func(o *Options)) (*rkv, error)
- type BoolOutput
- type BytesOutput
- type Cmdable
- type DelOptions
- type ExpireOptions
- type GetOptions
- type Mutex
- type MutexOptions
- type Options
- type RedisMessage
- type SetOptions
- type StatusOutput
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrRedisNotReady = errors.New("redis is not ready")
ErrRedisNotReady redis is not ready
View Source
var Key = func(key string) keyword {
return keyword(key)
}
Key keyword of key
View Source
var KeyPrefix = func(prefix string) func(key string) keyword { return func(key string) keyword { var builder strings.Builder builder.WriteString(prefix) builder.WriteString(key) return keyword(builder.String()) } }
KeyPrefix keyword of prefix
View Source
var KeySuffix = func(suffix string) func(key string) keyword { return func(key string) keyword { var builder strings.Builder builder.WriteString(key) builder.WriteString(suffix) return keyword(builder.String()) } }
KeySuffix keyword of suffix
Functions ¶
Types ¶
type BytesOutput ¶
type BytesOutput struct {
// contains filtered or unexported fields
}
BytesOutput .
type Cmdable ¶
Cmdable redis.Cmdable
var RedisClient Cmdable = func(o *Options) (redis.Cmdable, func() error) {
client := redis.NewClient(&redis.Options{
Addr: o.Addrs[0],
Username: o.Username,
Password: o.Password,
MaxRetries: o.MaxRetries,
DialTimeout: o.Timeout,
ReadTimeout: o.Timeout,
WriteTimeout: o.Timeout,
})
return client, client.Close
}
RedisClient redis client
var RedisCluster Cmdable = func(o *Options) (redis.Cmdable, func() error) {
cluster := redis.NewClusterClient(&redis.ClusterOptions{
Addrs: o.Addrs,
Username: o.Username,
Password: o.Password,
MaxRetries: o.MaxRetries,
DialTimeout: o.Timeout,
ReadTimeout: o.Timeout,
WriteTimeout: o.Timeout,
})
return cluster, cluster.Close
}
RedisCluster redis cluster
type ExpireOptions ¶
type ExpireOptions struct { Context context.Context // TTL key 过期时间 TTL time.Duration // Expiry key 过期时间。TTL 和 Expiry 同时设置时,以 Expiry 为准 Expiry time.Time }
ExpireOptions .
type GetOptions ¶
type GetOptions struct { Context context.Context // Marshaler value 编码方式 Marshaler codec.Marshaler }
GetOptions .
type MutexOptions ¶
type MutexOptions struct { Context context.Context // Interval 尝试获取锁的时间间隔 Interval time.Duration // TTL 加锁后,超时自动删除锁 TTL time.Duration }
MutexOptions .
type Options ¶
type Options struct { Context context.Context Addrs []string Username string Password string // Timeout second Timeout time.Duration // MaxRetries 命令执行失败时的重试次数 MaxRetries int // Cmdable redis redis.Cmdable Cmdable Cmdable }
Options .
type RedisMessage ¶
type RedisMessage struct { Data interface{} `json:"data"` CreatedBy string `json:"created_by"` CreatedAt string `json:"created_at"` }
RedisMessage .
type SetOptions ¶
type SetOptions struct { Context context.Context // TTL key 过期时间 TTL time.Duration // Expiry key 过期时间。TTL 和 Expiry 同时设置时,以 Expiry 为准 Expiry time.Time // Marshaler value 编码方式 Marshaler codec.Marshaler }
SetOptions .
type StatusOutput ¶
type StatusOutput struct {
// contains filtered or unexported fields
}
StatusOutput .
Click to show internal directories.
Click to hide internal directories.