cache

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ActiveServer = RedisState(0)
	DownServer   = RedisState(1)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	*RedisManager
}

Cache

func NewCache

func NewCache(conf *config.Config) (*Cache, error)

NewCache 从配置初始化缓存 配置了的 redis 连接失败会返回错误(fail-fast);完全没配置 redis 时返回可用的空实例

func (*Cache) Close added in v0.2.0

func (c *Cache) Close() error

Close 关闭所有缓存连接

type Redis

type Redis struct {
	*redis.Client
	State   RedisState `json:"state"`
	Options *redis.Options
}

func NewRedis

func NewRedis(client *redis.Client, options *redis.Options) *Redis

func (*Redis) GetClient

func (r *Redis) GetClient() *redis.Client

func (Redis) IsEqual

func (r Redis) IsEqual(options *redis.Options) bool

func (*Redis) MarshalJSON

func (this *Redis) MarshalJSON() ([]byte, error)

type RedisManager

type RedisManager struct {
	// contains filtered or unexported fields
}

func NewRedisManager

func NewRedisManager(conf *config.Config) (*RedisManager, error)

NewRedisManager 从配置初始化所有 redis 连接 配置了的 redis 必须连接成功(ping),否则返回错误(fail-fast); 完全没有 redis 配置时返回空 manager,不报错。

func (*RedisManager) Close added in v0.2.0

func (rm *RedisManager) Close() error

Close 关闭所有Redis连接

func (*RedisManager) Get

func (rm *RedisManager) Get(redisConfigCenterKey string) (*Redis, error)

func (*RedisManager) Names added in v0.3.0

func (rm *RedisManager) Names() []string

Names 返回所有已初始化的 redis 配置名

func (*RedisManager) PingAll added in v0.3.0

func (rm *RedisManager) PingAll(ctx context.Context) map[string]error

PingAll 对所有 redis 执行 Ping,返回每个实例的结果(nil 表示正常)

type RedisState

type RedisState int

Jump to

Keyboard shortcuts

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