package
module
Version:
v0.0.4
Opens a new window with list of versions in this module.
Published: May 8, 2025
License: MIT
Opens a new window with license information.
Imports: 6
Opens a new window with list of imports.
Imported by: 4
Opens a new window with list of known importers.
README
¶
redisx
封装了 go-redis,支持单机和集群
配置
type Config struct {
// 是否为集群模式
Cluster bool `mapstructure:"cluster" `
// 主机
Host string `mapstructure:"host" `
// 端口
Port string `mapstructure:"port" `
// 密码
Password string `mapstructure:"password"`
// 连接协议
Protocol string `mapstructure:"protocol"`
// 初始连接的数据库
Database int `mapstructure:"database"`
// 最小空闲连接
MinIdleConns int `mapstructure:"min_idle_conns"`
// 空闲时间
IdleTimeout int `mapstructure:"idle_timeout"`
// 连接池大小
PoolSize int `mapstructure:"pool_size"`
// 连接最大可用时间
MaxConnAge int `mapstructure:"max_conn_age"`
// 键前缀
Prefix string `mapstructure:"prefix"`
}
安装
go get -u -v github.com/itmisx/redisx
使用
参考 redix_test.go,详细请查看 github: https://github.com/go-redis/redis
Documentation
¶
func New(conf Config) redis.UniversalClient
New 新建redis实例
type Config struct {
Addrs []string `mapstructure:"addrs"`
MasterName string `mapstructure:"master_name"`
Password string `mapstructure:"password"`
DB int `mapstructure:"db"`
MinIdleConns int `mapstructure:"min_idle_conns"`
IdleTimeout int `mapstructure:"idle_timeout"`
PoolSize int `mapstructure:"pool_size"`
MaxConnAge int `mapstructure:"max_conn_age"`
Prefix string `mapstructure:"prefix"`
}
Redis 配置项
Source Files
¶
Click to show internal directories.
Click to hide internal directories.