Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- type Cmd
- type Config
- type Conn
- type Locker
- type Manager
- type Result
- func Del(ctx context.Context, key string) Result
- func Do(ctx context.Context, args ...any) (res Result)
- func Expire(ctx context.Context, key string, second int) Result
- func Get(ctx context.Context, key string) Result
- func NewResult(cmd *gr.Cmd) Result
- func Set(ctx context.Context, key string, value any) Result
- func SetEx(ctx context.Context, key string, value any, seconds ...int) Result
- func SetNx(ctx context.Context, key string, value any, seconds ...int) Result
Constants ¶
View Source
const ( DefaultHost = "127.0.0.1" DefaultNetwork = "tcp" DefaultPort = 6379 DefaultMaxActive = 10 DefaultMinIdle = 2 DefaultMaxLifetime = 60 DefaultTimeoutDial = 5 DefaultTimeoutRead = 3 DefaultTimeoutWrite = 3 )
View Source
const ( DefaultLockTimeout = 60 DefaultLockRenew = 3 DefaultLockPrefix = "__LOCKER__" )
Variables ¶
View Source
var (
Nil = gr.Nil
)
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Network string `yaml:"network" json:"network" label:"模式"` Host string `yaml:"host" json:"host" label:"主机"` Port int `yaml:"port" json:"port" label:"端口"` Password string `yaml:"password" json:"password" label:"密码"` Database int `yaml:"database" json:"database" label:"数据库号"` MaxActive int `yaml:"max-active" json:"max_active" label:"最大连接数"` MaxLifetime int `yaml:"max-lifetime" json:"max_lifetime" label:"连接生命周期"` MinIdle int `yaml:"min-idle" json:"min_idle" label:"最小连接"` DialTimeout int `yaml:"dial-timeout" json:"dial_timeout" label:"连接超时"` ReadTimeout int `yaml:"read-timeout" json:"read_timeout" label:"读取超时"` WriteTimeout int `yaml:"write-timeout" json:"write_timeout" label:"写入超时"` Logger bool `yaml:"log-command" json:"logger"` // contains filtered or unexported fields }
Config 全局配置.
type Locker ¶
type Locker interface { // Release // 释放锁资源. Release() // Renew // 资源续期. Renew(seconds ...int) }
Locker 分布式锁操作.
type Manager ¶ added in v1.2.0
type Manager interface { // Client // 读客户端. Client() *Client // Config // 配置实例. Config() *Config // Connect // 获取连接. Connect(ctx context.Context) *Conn }
Manager 管理器接口.
var (
Mgr Manager
)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.