Documentation
¶
Overview ¶
Package cache implements an on-disk cache for the encrypted audio files downloaded from the Spotify CDN.
Only the raw, still-encrypted bytes are stored: a cached file is useless without a valid audio key retrieved per playback, mirroring the behaviour of the reference librespot implementation. Files are keyed by their Spotify file id and evicted least-recently-used once an optional size limit is reached.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache stores encrypted audio files on disk under <dir>/audio.
func New ¶
New creates an audio file cache rooted at dir. When sizeLimit is greater than zero, least-recently-used files are evicted to keep the cache within the limit; a value of zero disables eviction (unbounded cache).
func (*Cache) File ¶
func (c *Cache) File(fileId []byte) (librespot.SizedReadAtSeeker, bool)
File returns a reader for the cached encrypted audio file, if present. The boolean reports whether the file was found. Accessing a file refreshes its recency for LRU eviction.
func (*Cache) SaveFile ¶
SaveFile stores the encrypted audio file identified by fileId, reading its contents from r. Writing is atomic: the data is written to a temporary file and renamed into place, so a crash never leaves a truncated cache entry. After a successful write, least-recently-used files are evicted when a size limit is configured.