cache

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchData

func FetchData(key string, obj any) error

func FetchDataWithCustomFunc

func FetchDataWithCustomFunc(key string, obj any, getFunc func() (any, error)) error

func GetCache added in v1.2.0

func GetCache(key string) (string, bool)

GetCache retrieves a value using the initialized cache implementation.

func Init added in v1.2.0

func Init(config Config)

Init initializes the global cache instance based on the configuration

func SetCache added in v1.2.0

func SetCache(key string, value string, expiration time.Duration) error

SetCache stores a key-value pair using the initialized cache implementation.

func StoreData

func StoreData(obj any) (key string)

Types

type Cache added in v1.2.0

type Cache interface {
	Set(key string, value string, expiration time.Duration) error
	Get(key string) (string, bool)
}

Cache defines the behavior for our cache implementations

type CacheType added in v1.2.0

type CacheType string
const (
	CacheMap   CacheType = "map"
	CacheRedis CacheType = "redis"
)

type Config added in v1.2.0

type Config struct {
	Type  CacheType   `json:"type" yaml:"type"`
	Redis ConfigRedis `json:"redis" yaml:"redis"`
}

type ConfigRedis added in v1.2.0

type ConfigRedis struct {
	Host     string `json:"host" yaml:"host"`
	Port     string `json:"port" yaml:"port"`
	User     string `json:"user" yaml:"user"`
	Password string `json:"password" yaml:"password"`
}

Jump to

Keyboard shortcuts

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