cache

package
v0.0.0-...-ab6c89e Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr     string        `mapstructure:"addr"`
	Password string        `mapstructure:"password"`
	DB       int           `mapstructure:"db"`
	TTL      time.Duration `mapstructure:"ttl"`
}

Config struct for Redis configuration

type ICache

type ICache[T any] interface {
	Get(key interface{}) (T, bool)
	Set(key interface{}, val T) bool
}

ICache interface with generics

type RedisCache

type RedisCache[T any] struct {
	// contains filtered or unexported fields
}

RedisCache struct implementing ICache interface

func NewRedisCache

func NewRedisCache[T any](config *Config, logger logger.ILogger) *RedisCache[T]

NewRedisCache returns a new RedisCache with provided config

func (*RedisCache[T]) Get

func (r *RedisCache[T]) Get(key interface{}) (T, bool)

Get method retrieves value by key from Redis

func (*RedisCache[T]) Set

func (r *RedisCache[T]) Set(key interface{}, val T) bool

Set method stores key-value pair in Redis with TTL

Jump to

Keyboard shortcuts

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