cache

package
v0.0.0-...-d1e33dd Latest Latest
Warning

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

Go to latest
Published: May 24, 2025 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("cache",
	fx.Provide(NewCache),
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Set(key string, value interface{}) error
	Get(key string, dest interface{}) error
	Delete(key string) error
}

func NewCache

func NewCache(conf *CacheConfig) Cache

NewRedisCache creates a new RedisCache with a given TTL (time-to-live).

type CacheConfig

type CacheConfig struct {
	Addr           string
	TTL            time.Duration
	Host           string
	Port           int
	Password       string
	DB             int
	ConnectTimeout time.Duration
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
}

type RedisCache

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

RedisCache struct defines the cache.

func (*RedisCache) Delete

func (r *RedisCache) Delete(key string) error

Delete removes a cached value from Redis.

func (*RedisCache) Get

func (r *RedisCache) Get(key string, dest interface{}) error

Get retrieves a cached value from Redis.

func (*RedisCache) Set

func (r *RedisCache) Set(key string, value interface{}) error

Set caches a value in Redis.

type RedisCacheImpl

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

RedisCache struct defines the cache.

func (*RedisCacheImpl) Delete

func (r *RedisCacheImpl) Delete(ctx context.Context, key string) error

Delete removes a cached value from Redis.

func (*RedisCacheImpl) Get

func (r *RedisCacheImpl) Get(ctx context.Context, key string, dest interface{}) error

Get retrieves a cached value from Redis.

func (*RedisCacheImpl) Set

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

Set caches a value in Redis.

Jump to

Keyboard shortcuts

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