cache

package
v0.0.0-...-146b0ff Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RewardsKeyPrefix    = "rewards"
	ValidatorsKeyPrefix = "validators"

	// {prefix}_{evm_address}
	RewardsKeyFormat = "%s_%s"
	// {prefix}_{status}_{page.key}_{page.offset}_{page.limit}_{page.count_total}_{page.reverse}
	ValidatorsKeyFormat = "%s_%s_%s_%s_%s_%s_%s"
)
View Source
const (
	DefaultRedisConfigPrefix = "redis"

	RedisPasswordModePlain = "plain"
	RedisPasswordModeGCP   = "gcp-secret-manager"
)
View Source
const (
	DefaultCacheTTL = time.Hour
)

Variables

This section is empty.

Functions

func GetRedisData

func GetRedisData(ctx context.Context, rdb *redis.Client, key string) (string, error)

func InvalidateRedisData

func InvalidateRedisData(ctx context.Context, rdb *redis.Client, key string) error

func InvalidateRedisDataByPrefix

func InvalidateRedisDataByPrefix(ctx context.Context, rdb *redis.Client, prefix string) error

func NewRedisClient

func NewRedisClient(ctx context.Context, configFile string) (*redis.Client, error)

func RewardsKey

func RewardsKey(evmAddr string) string

func SetRedisData

func SetRedisData(ctx context.Context, rdb *redis.Client, key string, data string) error

func ValidatorsKey

func ValidatorsKey(params map[string]string) string

Types

type RedisConfig

type RedisConfig struct {
	Addr         string `yaml:"addr" envconfig:"ADDR"`
	PasswordMode string `yaml:"password-mode" envconfig:"PASSWORD_MODE"`
	Password     string `yaml:"password" envconfig:"PASSWORD"`
	DB           int    `yaml:"db" envconfig:"DB"`
}

Jump to

Keyboard shortcuts

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