Documentation
¶
Overview ¶
Package redis MIT License
# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package redis MIT License
# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package redis MIT License
# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- type Client
- type Config
- type Option
- func WithAddress(address []string) Option
- func WithClientName(clientName string) Option
- func WithConnMaxIdleTime(connMaxIdleTime time.Duration) Option
- func WithConnMaxLifetime(connMaxLifetime time.Duration) Option
- func WithContextTimeoutEnabled(contextTimeoutEnabled bool) Option
- func WithDB(db int) Option
- func WithDialTimeout(dialTimeout time.Duration) Option
- func WithDialer(dialer func(ctx context.Context, network, addr string) (net.Conn, error)) Option
- func WithMMaxIdleConns(maxIdleConns int) Option
- func WithMasterName(masterName string) Option
- func WithMaxActiveConns(maxActiveConns int) Option
- func WithMaxRedirects(maxRedirects int) Option
- func WithMaxRetries(maxRetries int) Option
- func WithMaxRetryBackoff(maxRetryBackoff time.Duration) Option
- func WithMinIdleConns(minIdleConns int) Option
- func WithMinRetryBackoff(minRetryBackoff time.Duration) Option
- func WithOnConnect(onConnect func(ctx context.Context, cn *redis.Conn) error) Option
- func WithPassword(password string) Option
- func WithPoolSize(poolSize int) Option
- func WithProtocol(protocol int) Option
- func WithReadOnly(readOnly bool) Option
- func WithReadTimeout(readTimeout time.Duration) Option
- func WithRouteByLatency(routeByLatency bool) Option
- func WithRouteRandomly(routeRandomly bool) Option
- func WithSentinelPassword(sentinelUsername string) Option
- func WithSentinelUsername(sentinelUsername string) Option
- func WithTLSConfig(tLSConfig *tls.Config) Option
- func WithTLSFile(certFile, keyFile string) Option
- func WithUsername(username string) Option
- func WithWriteTimeout(writeTimeout time.Duration) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client = redis.UniversalClient
Client redis client
func NewWithConfig ¶
NewWithConfig create Client with Config
type Config ¶
type Config struct { Address []string `json:"address"` ClientName string `json:"client_name"` // Database to be selected after connecting to the server. // Only single-node and failover clients. DB int `json:"db"` Dialer func(ctx context.Context, network, addr string) (net.Conn, error) `json:"-"` OnConnect func(ctx context.Context, cn *redis.Conn) error `json:"-"` Protocol int `json:"protocol"` Username string `json:"username"` Password string `json:"password"` SentinelUsername string `json:"sentinel_username"` SentinelPassword string `json:"sentinel_password"` MaxRetries int `json:"max_retries"` MinRetryBackoff time.Duration `json:"min_retry_backoff"` MaxRetryBackoff time.Duration `json:"max_retry_backoff"` DialTimeout config.Duration `json:"dial_timeout"` ReadTimeout config.Duration `json:"read_timeout"` WriteTimeout config.Duration `json:"write_timeout"` ContextTimeoutEnabled bool `json:"context_timeout_enabled"` // PoolFIFO uses FIFO mode for each node connection pool GET/PUT (default LIFO). PoolFIFO bool `json:"pool_fifo"` PoolSize int `json:"pool_size"` PoolTimeout config.Duration `json:"pool_timeout"` MinIdleConns int `json:"min_idle_conns"` MaxIdleConns int `json:"max_idle_conns"` MaxActiveConns int `json:"max_active_conns"` ConnMaxIdleTime config.Duration `json:"conn_max_idle_time"` ConnMaxLifetime config.Duration `json:"conn_max_lifetime"` // TLS config TLSConfig *tls.Config `json:"-"` CertFile string `json:"cert_file"` KeyFile string `json:"key_file"` MaxRedirects int `json:"max_redirects"` ReadOnly bool `json:"read_only"` RouteByLatency bool `json:"route_by_latency"` RouteRandomly bool `json:"route_randomly"` MasterName string `json:"master_name"` DisableIndentity bool `json:"disable_indentity"` IdentitySuffix string `json:"identity_suffix"` }
Config redis config
func ScanConfig ¶
ScanConfig scan config name to Config value
func (*Config) WithOption ¶
WithOption apply option
type Option ¶
type Option func(c *Config)
Option create a redis client option
func WithAddress ¶
WithAddress with a redis address option
func WithClientName ¶
WithClientName with a redis client name option
func WithConnMaxIdleTime ¶
WithConnMaxIdleTime with a redis conn max idle time option
func WithConnMaxLifetime ¶
WithConnMaxLifetime with a redis conn max lifet time option
func WithContextTimeoutEnabled ¶
WithContextTimeoutEnabled with a context timout enable
func WithDB ¶
WithDB Database to be selected after connecting to the server. Only single-node and failover clients.
func WithDialTimeout ¶
WithDialTimeout with a redis clint dial timeout option
func WithDialer ¶
WithDialer with a client Dialer option
func WithMMaxIdleConns ¶
WithMMaxIdleConns with a redis client MaxIdleConns option
func WithMasterName ¶
WithMasterName with MasterName option
func WithMaxActiveConns ¶
WithMaxActiveConns with a redis client MaxActiveConns option
func WithMaxRedirects ¶
WithMaxRedirects with a redis client MaxRedirects option
func WithMaxRetries ¶
WithMaxRetries with a redis client max retries
func WithMaxRetryBackoff ¶
WithMaxRetryBackoff with a redis client MaxRetryBackoff option
func WithMinIdleConns ¶
WithMinIdleConns with a redis client minIdleConns
func WithMinRetryBackoff ¶
WithMinRetryBackoff with a redis client MinRetryBackoff option
func WithOnConnect ¶
WithOnConnect with a client connect callback option
func WithPassword ¶
WithPassword with a redis password option
func WithPoolSize ¶
WithPoolSize with a redis client pool size option
func WithProtocol ¶
WithProtocol with a client protocol option
func WithReadOnly ¶
WithReadOnly with a redis client readOnly option
func WithReadTimeout ¶
WithReadTimeout with a redis client read timeout option
func WithRouteByLatency ¶
WithRouteByLatency with a redis client RouteByLatency option
func WithRouteRandomly ¶
WithRouteRandomly with a redis client RouteByLatency option
func WithSentinelPassword ¶
WithSentinelPassword with a redis SentinelPassword option
func WithSentinelUsername ¶
WithSentinelUsername with a redis SentinelUsername option
func WithTLSConfig ¶
WithTLSConfig with tls.Config option
func WithTLSFile ¶
WithTLSFile with TLS file path option
func WithUsername ¶
WithUsername with a redis client username option
func WithWriteTimeout ¶
WithWriteTimeout with a redis client writeTimeout option