redkit

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Discard = helper.NilError("redkit: discarded")

Discard 丢弃数据,不缓存

Variables

This section is empty.

Functions

func Del

func Del(ctx context.Context, uc redis.UniversalClient, key string) error

func Get

func Get[T any](ctx context.Context, uc redis.UniversalClient, key string, fn func(ctx context.Context) (T, error), ttl time.Duration) (T, error)

func HDel

func HDel(ctx context.Context, uc redis.UniversalClient, key, field string) error

func HGet

func HGet[T any](ctx context.Context, uc redis.UniversalClient, key, field string, fn func(ctx context.Context) (T, error), ttl time.Duration) (T, error)

func HGetAll

func HGetAll[T any](ctx context.Context, uc redis.UniversalClient, key string) (map[string]T, error)

func HMGetMap

func HMGetMap[T any](ctx context.Context, uc redis.UniversalClient, key string, fields []string) (map[string]T, error)

func HMGetStrMap

func HMGetStrMap(ctx context.Context, uc redis.UniversalClient, key string, fields []string) (map[string]string, error)

func MGetMap

func MGetMap[T any](ctx context.Context, uc redis.UniversalClient, keys []string) (map[string]T, error)

func MGetStrMap

func MGetStrMap(ctx context.Context, uc redis.UniversalClient, keys []string) (map[string]string, error)

func NewClient

func NewClient(cfg *Config) (redis.UniversalClient, error)

Types

type Config

type Config struct {
	// Addrs 地址
	Addrs []string `json:"addrs" mapstructure:"addrs"`
	// Options 选项
	Options Options `json:"options" mapstructure:"options"`
}

type Options

type Options struct {
	// DB 数据库
	DB int `json:"db" mapstructure:"db"`
	// Username 用户名
	Username string `json:"username" mapstructure:"username"`
	// Password 密码
	Password string `json:"password" mapstructure:"password"`
	// DialTimeout 连接超时时间(单位:秒)
	DialTimeout int `json:"dial_timeout" mapstructure:"dial_timeout"`
	// ReadTimeout 读取超时时间(单位:秒)
	ReadTimeout int `json:"read_timeout" mapstructure:"read_timeout"`
	// WriteTimeout 写入超时时间(单位:秒)
	WriteTimeout int `json:"write_timeout" mapstructure:"write_timeout"`
	// PoolSize 连接池大小
	PoolSize int `json:"pool_size" mapstructure:"pool_size"`
	// PoolTimeout 连接池超时时间(单位:秒)
	PoolTimeout int `json:"pool_timeout" mapstructure:"pool_timeout"`
	// MinIdleConns 最小空闲连接数
	MinIdleConns int `json:"min_idle_conns" mapstructure:"min_idle_conns"`
	// MaxIdleConns 最大空闲连接数
	MaxIdleConns int `json:"max_idle_conns" mapstructure:"max_idle_conns"`
	// MaxActiveConns 最大活跃连接数
	MaxActiveConns int `json:"max_active_conns" mapstructure:"max_active_conns"`
	// ConnMaxIdleTime 连接最大闲置时间(单位:秒)
	ConnMaxIdleTime int `json:"conn_max_idle_time" mapstructure:"conn_max_idle_time"`
	// ConnMaxLifetime 连接最大生命时长(单位:秒)
	ConnMaxLifetime int `json:"conn_max_lifetime" mapstructure:"conn_max_lifetime"`
	// InsecureSkipVerify 是否跳过证书验证
	InsecureSkipVerify bool `json:"insecure_skip_verify" mapstructure:"insecure_skip_verify"`
}

Jump to

Keyboard shortcuts

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