Documentation
¶
Index ¶
- func NewModel(c *Client, name string) *model
- type Client
- type Config
- type Model
- type Option
- func WithAddrs(addrs ...string) Option
- func WithDatabase(database int) Option
- func WithDialTimeout(dialTimeout int) Option
- func WithIdleTimeout(idleTimeout int) Option
- func WithMinIdleConns(minIdleConns int) Option
- func WithPassword(password string) Option
- func WithPoolSize(poolSize int) Option
- func WithPoolTimeout(poolTimeout int) Option
- func WithReadTimeout(readTimeout int) Option
- func WithUsername(username string) Option
- func WithWriteTimeout(writeTimeout int) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func GetGlobalClient ¶
func GetGlobalClient() *Client
func NewClientWithOptions ¶
func NewGlobalClient ¶
NewGlobalClient If there is only one Mongo, you can select the global client
func (*Client) Kernel ¶
func (c *Client) Kernel() redis.UniversalClient
type Config ¶
type Config struct {
Addrs []string `mapstructure:"addrs" json:"addrs"`
Username string `mapstructure:"username" json:"username"`
Password string `mapstructure:"password" json:"password"`
Database int `mapstructure:"db" json:"db"`
// 连接超时秒数
// Default is 5 seconds.
DialTimeout int `mapstructure:"dial_timeout" json:"dial_timeout"`
// Timeout for socket reads. If reached, commands will fail
// with a timeout instead of blocking. Use value -1 for no timeout and 0 for default.
// Default is 3 seconds.
ReadTimeout int `mapstructure:"read_timeout" json:"read_timeout"`
// Timeout for socket writes. If reached, commands will fail
// with a timeout instead of blocking.
// Default is ReadTimeout.
WriteTimeout int `mapstructure:"write_timeout" json:"write_timeout"`
// 连接池容最大量
// Default is 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
PoolSize int `mapstructure:"pool_size" json:"pool_size"`
// 连接池保持连接状态的最小可用连接数
// because new connection is slow.
MinIdleConns int `mapstructure:"min_idle_conns" json:"min_idle_conns"`
// 连接池全部连接都被占用时的超时时间(秒)
// Default is ReadTimeout + 1 second.
PoolTimeout int `mapstructure:"pool_timeout" json:"pool_timeout"`
// 关闭空闲连接的时间(秒)
// Should be less than server's timeout.
// Default is 5 minutes. -1 disables idle timeout check.
IdleTimeout int `mapstructure:"idle_timeout" json:"idle_timeout"`
}
func (Config) Convert2Otions ¶
func (c Config) Convert2Otions() *redis.UniversalOptions
type Option ¶
type Option func(config *Config)
func WithDatabase ¶
func WithDialTimeout ¶
func WithIdleTimeout ¶
func WithMinIdleConns ¶
func WithPassword ¶
func WithPoolSize ¶
func WithPoolTimeout ¶
func WithReadTimeout ¶
func WithUsername ¶
func WithWriteTimeout ¶
Click to show internal directories.
Click to hide internal directories.