Documentation
¶
Index ¶
- type MemoryCache
- func (c *MemoryCache) Delete(key string) error
- func (c *MemoryCache) Get(key string) (*domain.ExchangeRate, error)
- func (c *MemoryCache) GetLastUpdate(key string) (time.Time, error)
- func (c *MemoryCache) Set(key string, rate *domain.ExchangeRate, ttl time.Duration) error
- func (c *MemoryCache) SetLastUpdate(key string, t time.Time) error
- type RedisExchangeRateCache
- func (r *RedisExchangeRateCache) Delete(key string) error
- func (r *RedisExchangeRateCache) Get(key string) (*domain.ExchangeRate, error)
- func (r *RedisExchangeRateCache) GetLastUpdate(key string) (time.Time, error)
- func (r *RedisExchangeRateCache) Set(key string, rate *domain.ExchangeRate, ttl time.Duration) error
- func (r *RedisExchangeRateCache) SetLastUpdate(key string, t time.Time) error
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 (r *RedisExchangeRateCache) Get(key string) (*domain.ExchangeRate, error)
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
Click to show internal directories.
Click to hide internal directories.