cachex

package
v0.0.0-...-7c465ed Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear(db string) error

清空无失效时间的db空间

func Del

func Del(db, key string) error

删除无失效时间的key

func Delex

func Delex(key string) error

删除有失效时间的key

func GetString

func GetString(db, key string) (string, error)

获取无失效时间的字符串

func GetStruct

func GetStruct(db, key string, reply any) error

获取无失效时间的结构体

func GetexString

func GetexString(key string) (string, error)

获取有失效时间的字符串

func GetexStruct

func GetexStruct(key string, reply any) error

获取有失效时间的结构体

func Init

func Init(cfg CacheConfig)

初始化

func SetString

func SetString(db, key, value string) error

保存无失效时间的字符串

func SetStruct

func SetStruct(db, key string, value any) error

保存无失效时间的结构体

func SetexString

func SetexString(key, value string, expires int) error

保存有失效时间的字符串(单位:秒)

func SetexStruct

func SetexStruct(key string, value any, expires int) error

保存有失效时间的结构体(单位: 秒)

Types

type CacheConfig

type CacheConfig struct {
	Mode   string     `mapstructure:"mode"`
	Prefix string     `mapstructure:"prefix"`
	Addrs  []string   `mapstructure:"addrs"`
	Pool   PoolConfig `mapstructure:"pool"`
	Dial   DialConfig `mapstructure:"dial"`
}

缓存配置

type DialConfig

type DialConfig struct {
	ReadTimeout    int    `mapstructure:"read-timeout"`
	WriteTimeout   int    `mapstructure:"write-timeout"`
	ConnectTimeout int    `mapstructure:"connect-timeout"`
	Password       string `mapstructure:"password"`
	Database       int    `mapstructure:"database"`
	KeepAlive      int    `mapstructure:"keep-alive"`
}

连接参数

type PoolConfig

type PoolConfig struct {
	MaxActive       int  `mapstructure:"max-active"`
	MaxIdle         int  `mapstructure:"max-idle"`
	Wait            bool `mapstructure:"wait"`
	IdleTimeout     int  `mapstructure:"idle-timeout"`
	MaxConnLifetime int  `mapstructure:"max-conn-lifetime"`
}

连接池配置

Jump to

Keyboard shortcuts

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