cache

package module
v0.0.0-...-7193066 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCacheCli

func GetCacheCli(config *CacheCfg) (*redis.Client, error)

Types

type CacheCfg

type CacheCfg struct {
	ClientName string `json:"client_name" yaml:"client_name" env:"name=CACHE_CLIENT_NAME"`
	Address    string `json:"address" yaml:"address" env:"name=CACHE_ADDRESS"`
	Username   string `json:"username" yaml:"username" env:"name=CACHE_USERNAME"`
	Password   string `json:"password" yaml:"password" env:"name=CACHE_PASSWORD"`
	DB         int    `json:"db" yaml:"db" env:"name=CACHE_DB"`
}

type HashCache

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

func NewHashCache

func NewHashCache(name string, cli *redis.Client) *HashCache

func (*HashCache) Del

func (c *HashCache) Del(ctx context.Context, keys ...string) error

func (*HashCache) Exist

func (c *HashCache) Exist(ctx context.Context, key string) (bool, error)

func (*HashCache) Get

func (c *HashCache) Get(ctx context.Context, key string) (string, error)

func (*HashCache) Set

func (c *HashCache) Set(ctx context.Context, key string, value interface{}) error

type ICache

type ICache interface {
	Get(ctx context.Context, key string) (string, error)
	Set(ctx context.Context, key string, value interface{}) error
	Del(ctx context.Context, keys ...string) error
	Exist(ctx context.Context, key string) (bool, error)
}

type SetCache

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

func NewSetCache

func NewSetCache(name string, cli *redis.Client) *SetCache

func (*SetCache) Del

func (c *SetCache) Del(ctx context.Context, members ...string) error

func (*SetCache) Exist

func (c *SetCache) Exist(ctx context.Context, member string) (bool, error)

func (*SetCache) Get

func (c *SetCache) Get(ctx context.Context, _ string) (string, error)

func (*SetCache) Set

func (c *SetCache) Set(ctx context.Context, member string, _ interface{}) error

type StrCache

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

func NewStrCache

func NewStrCache(cli *redis.Client, expire time.Duration) *StrCache

func (*StrCache) Del

func (c *StrCache) Del(ctx context.Context, keys ...string) error

func (*StrCache) Exist

func (c *StrCache) Exist(ctx context.Context, key string) (bool, error)

func (*StrCache) Get

func (c *StrCache) Get(ctx context.Context, key string) (string, error)

func (*StrCache) Set

func (c *StrCache) Set(ctx context.Context, key string, value interface{}) error

func (*StrCache) SetEx

func (c *StrCache) SetEx(ctx context.Context, key string, value interface{}, expire time.Duration) error

Jump to

Keyboard shortcuts

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