redis

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2023 License: MIT Imports: 10 Imported by: 0

README

gsf-redis

db config json

component

{
  "max_sock_read_time" : 3,
  "max_sock_write_time" : 3,
  "idle_check_time" : 3,
  "slow_threshold" : 3
}

client

{
  "host": "127.0.0.1:9800",
  "db": "",
  "user": "",
  "pwd": "",
  "min_idle_num" : 2,
  "max_con_num" : 10
}

命令行参数

--redis-sr-timeout value             redis connect socket read timeout (default: 0)
--redis-sw-timeout value             redis connect socket write timeout (default: 0)
--redis-cr-timeout value             redis client request timeout (default: 0)
--redis-check-idle-time value        redis idle timeout (default: 0)
--redis-slow-threshold value         redis slow threshold (default: 0)
--redis-{{key}}-open-limit value     redis({{key}}) max open limit (default: 0)
--redis-{{key}}-idle-min value       redis({{key}}) idle min limit (default: 0)
--redis-{{key}}-dsn value            redis({{key}}) DSN (format: redis://user:{{password}}@{{ip}}:{{port}}/{{db}}?{{options}})

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateClient = defaultNewClient

Functions

This section is empty.

Types

type Client added in v0.3.0

type Client struct {
	Client *redis.Client
	Cfg    ClientConfig
}

func (*Client) CliFlags added in v0.3.0

func (c *Client) CliFlags(name string) []cli.Flag

func (*Client) Load added in v0.3.0

func (c *Client) Load(name string, cfg *ComponentConfig) (err error)

type ClientConfig added in v0.3.0

type ClientConfig struct {
	Host       string `json:"host"         yaml:"host"`
	Pwd        string `json:"pwd"          yaml:"pwd"`
	DB         int    `json:"db"           yaml:"db"`
	MinIdleNum int    `json:"min_idle_num" yaml:"max_req_time"`
	MaxConnNum int    `json:"max_con_num"  yaml:"max_con_num"`
}

type Component

type Component struct {
	DSNPrint bool
	Cfg      ComponentConfig
	Clts     map[string]*Client
}

func (*Component) CliFlags

func (c *Component) CliFlags() []cli.Flag

func (*Component) Close

func (c *Component) Close() error

func (*Component) Init added in v0.0.6

func (c *Component) Init(l logger.Interface, cfg *gsf.AppConfig, ctx *cli.Context) error

func (*Component) LoadOne added in v0.3.0

func (c *Component) LoadOne(name string) (err error)

func (*Component) Run

func (c *Component) Run() (err error)

type ComponentConfig added in v0.3.0

type ComponentConfig struct {
	MaxReadTime    int `json:"max_sock_read_time"  yaml:"max_sock_read_time"`
	MaxWriteTime   int `json:"max_sock_write_time" yaml:"max_sock_write_time"`
	MaxRequestTime int `json:"max_request_time"    yaml:"max_request_time"`
	IdleCheckTime  int `json:"idle_check_time"     yaml:"idle_check_time"`
	SlowThreshold  int `json:"slow_threshold"      yaml:"slow_threshold"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL