cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package cache provides image caching functionality for station logos.

Index

Constants

View Source
const (
	// DefaultExpiry is how long cached images are valid (7 days).
	DefaultExpiry = 7 * 24 * time.Hour
	// ImageSubdir is the subdirectory for cached images.
	ImageSubdir = "images"
	// AppName is used for the cache directory name.
	AppName = "somafm"
)

Variables

This section is empty.

Functions

func GetCacheDir

func GetCacheDir() (string, error)

GetCacheDir returns the platform-specific cache directory for the application.

Types

type Cache

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

Cache manages disk-based caching of station logo images.

func NewCache

func NewCache() (*Cache, error)

NewCache creates a new Cache instance with the default expiry.

func (*Cache) CleanExpired

func (c *Cache) CleanExpired() error

CleanExpired removes cache files older than the expiry duration.

func (*Cache) GetImage

func (c *Cache) GetImage(url string) image.Image

GetImage retrieves a cached image by URL. Returns nil if not found or expired.

func (*Cache) SaveImage

func (c *Cache) SaveImage(url string, img image.Image) error

SaveImage stores an image in the cache, keyed by its URL.

Jump to

Keyboard shortcuts

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