cache

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryCache

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

MemoryCache implements ExchangeRateCache using in-memory storage

func NewMemoryCache

func NewMemoryCache() *MemoryCache

NewMemoryCache creates a new in-memory cache

func (*MemoryCache) Delete

func (c *MemoryCache) Delete(key string) error

Delete removes a rate from cache

func (*MemoryCache) Get

func (c *MemoryCache) Get(key string) (*domain.ExchangeRate, error)

Get retrieves a rate from cache

func (*MemoryCache) GetLastUpdate

func (c *MemoryCache) GetLastUpdate(key string) (time.Time, error)

GetLastUpdate returns the last update timestamp for a key

func (*MemoryCache) Set

func (c *MemoryCache) Set(
	key string,
	rate *domain.ExchangeRate,
	ttl time.Duration,
) error

Set stores a rate in cache with TTL

func (*MemoryCache) SetLastUpdate

func (c *MemoryCache) SetLastUpdate(key string, t time.Time) error

SetLastUpdate sets the last update timestamp for a key

type RedisExchangeRateCache

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

RedisExchangeRateCache implements ExchangeRateCache using Redis.

func NewRedisExchangeRateCache

func NewRedisExchangeRateCache(
	addr, password string,
	db int,
	prefix string,
) *RedisExchangeRateCache

NewRedisExchangeRateCache creates a new RedisExchangeRateCache.

func NewRedisExchangeRateCacheWithOptions

func NewRedisExchangeRateCacheWithOptions(
	opt *redis.Options,
	prefix string,
	logger *slog.Logger,
) *RedisExchangeRateCache

NewRedisExchangeRateCacheWithOptions creates a new RedisExchangeRateCache from redis.Options.

func (*RedisExchangeRateCache) Delete

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

func (*RedisExchangeRateCache) Get

func (*RedisExchangeRateCache) GetLastUpdate

func (r *RedisExchangeRateCache) GetLastUpdate(key string) (time.Time, error)

func (*RedisExchangeRateCache) Set

func (r *RedisExchangeRateCache) Set(
	key string,
	rate *domain.ExchangeRate,
	ttl time.Duration,
) error

func (*RedisExchangeRateCache) SetLastUpdate

func (r *RedisExchangeRateCache) SetLastUpdate(key string, t time.Time) error

Jump to

Keyboard shortcuts

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