Documentation ¶
Index ¶
- Variables
- type Callback
- type Option
- func WithConnMaxIdleTimeMS(ConnMaxIdleTimeMS int) Option
- func WithConnMaxLifetimeMS(ConnMaxLifetimeMS int) Option
- func WithDiscardUnknownColumns() Option
- func WithMaxIdleConns(MaxIdleConns int) Option
- func WithMaxOpenConns(MaxOpenConns int) Option
- func WithParallelCallback() Option
- func WithQueryTimeout(QueryTimeout time.Duration) Option
- func WithURL(URL string) Option
- type Options
- type Proxy
Constants ¶
This section is empty.
Variables ¶
var DB = New()
DB 默认的数据库代理对象
var DefaultOpts = Options{
URL: "sqlite://:memory:?cache=shared",
}
var ErrProxyAllreadySettedUniversalClient = errors.New("代理不能重复设置客户端对象")
ErrProxyAllreadySettedUniversalClient 代理已经设置过redis客户端对象
var ErrProxyNotYetSettedUniversalClient = errors.New("代理还未设置客户端对象")
ErrProxyNotYetSettedUniversalClient 代理还未设置客户端对象
var ErrUnSupportSchema = errors.New("未支持的数据库管理服务类型")
ErrUnSupportSchema 未支持的数据库管理服务类型
var ErrUnknownClientType = errors.New("未知的redis客户端类型")
ErrUnknownClientType 未知的redis客户端类型
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option interface {
Apply(*Options)
}
Option configures how we set up the connection.
func WithConnMaxIdleTimeMS ¶
WithConnMaxIdleTimeMS 设置连接池的最大空闲连接超时时间,单位ms
func WithConnMaxLifetimeMS ¶
WithConnMaxLifetimeMS 设置连接池的最大连接超时时间,单位ms
func WithDiscardUnknownColumns ¶
func WithDiscardUnknownColumns() Option
WithDiscardUnknownColumns 设置当有未知列时不报错
func WithMaxIdleConns ¶
WithMaxIdleConns 设置连接池的最大空闲连接数
func WithParallelCallback ¶
func WithParallelCallback() Option
WithParallelCallback 设置初始化后回调并行执行而非串行执行
func WithQueryTimeout ¶
WithQueryTimeout 设置最大请求超时,单位ms
type Options ¶
type Options struct { URL string Parallelcallback bool QueryTimeout time.Duration MaxOpenConns int ConnMaxLifetime time.Duration MaxIdleConns int ConnMaxIdleTime time.Duration DiscardUnknownColumns bool }
Option 设置key行为的选项 @attribute MaxTTL time.Duration 为0则不设置过期 @attribute AutoRefresh string 需要为crontab格式的字符串,否则不会自动定时刷新
type Proxy ¶
Proxy bun客户端的代理
func (*Proxy) NewCtx ¶
func (proxy *Proxy) NewCtx() (ctx context.Context, cancel context.CancelFunc)
NewCtx 根据注册的超时时间构造一个上下文
func (*Proxy) SetConnect ¶
SetConnect 设置连接的客户端 @params cli *bun.DB bun的DB对象