cache

package
v0.0.0-...-0f61cfb Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LiveMatchTTL   = 5 * time.Minute
	FixtureTTL     = 6 * time.Hour
	TeamInfoTTL    = 24 * time.Hour
	LeagueTableTTL = 12 * time.Hour
	LineupTTL      = 12 * time.Hour
	StandingsTTL   = 6 * time.Hour
	NewsTTL        = 30 * time.Minute
	DefaultTTL     = 1 * time.Hour
)

Cache TTL constants for different types of data

View Source
const (
	StatusLive      = "LIVE"
	StatusInPlay    = "IN_PLAY"
	StatusScheduled = "SCHEDULED"
	StatusFinished  = "FINISHED"
)

Match status constants

Variables

This section is empty.

Functions

func GetMatchTTL

func GetMatchTTL(status string) time.Duration

GetMatchTTL returns the appropriate TTL based on match status

Types

type Cache

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

func NewCache

func NewCache(redisURL string) (*Cache, error)

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, key string) error

Delete removes a key from the cache

func (*Cache) DeletePattern

func (c *Cache) DeletePattern(ctx context.Context, pattern string) error

DeletePattern removes all keys matching a pattern

func (*Cache) Exists

func (c *Cache) Exists(ctx context.Context, key string) (bool, error)

Exists checks if a key exists in the cache

func (*Cache) FlushAll

func (c *Cache) FlushAll(ctx context.Context) error

FlushAll removes all keys from the cache

func (*Cache) Get

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

Get retrieves a value from the cache by key and unmarshals it into the provided interface

func (*Cache) GetStats

func (c *Cache) GetStats(ctx context.Context) (map[string]interface{}, error)

GetStats returns basic cache statistics

func (*Cache) HealthCheck

func (c *Cache) HealthCheck(ctx context.Context) error

HealthCheck performs a health check on the Redis connection

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error

Set stores a value in the cache with the given key and expiration time

type CacheInterface

type CacheInterface interface {
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error
	Get(ctx context.Context, key string, dest interface{}) error
	Exists(ctx context.Context, key string) (bool, error)
	Delete(ctx context.Context, key string) error
	DeletePattern(ctx context.Context, pattern string) error
	FlushAll(ctx context.Context) error
	HealthCheck(ctx context.Context) error
	GetStats(ctx context.Context) (map[string]interface{}, error)
}

CacheInterface defines the interface for cache operations

Jump to

Keyboard shortcuts

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