librarycache

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: GPL-3.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package librarycache stores complete account library snapshots on disk.

Package librarycache defines the persistent library snapshot contract.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExist = fs.ErrNotExist

ErrNotExist identifies an account without a stored snapshot.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Load(account string) (Snapshot, error)
	Generation(account string) uint64
	Save(account string, generation, revision uint64, data Snapshot) error
	PreparePurge(account string) func() error
	Purge(account string) error
	PurgeAll() error
}

Cache is the account-scoped library cache used by the app.

type Snapshot

type Snapshot struct {
	Playlists []model.Playlist         `json:"playlists"`
	Listings  map[string]model.Listing `json:"listings"`
}

Snapshot contains only complete remote listings.

type Store

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

Store serializes writes and fences writes queued before Purge.

func New

func New(dir string) *Store

func (*Store) Generation

func (s *Store) Generation(account string) uint64

Generation identifies the current account cache epoch. A caller captures it before starting background work and supplies it to Save.

func (*Store) Load

func (s *Store) Load(account string) (Snapshot, error)

func (*Store) PreparePurge

func (s *Store) PreparePurge(account string) func() error

PreparePurge fences old writes immediately without waiting for file I/O. The returned cleanup can run off the UI loop. A snapshot saved in the new generation before cleanup starts is retained.

func (*Store) Purge

func (s *Store) Purge(account string) error

Purge is the synchronous form used by the CLI and store tests.

func (*Store) PurgeAll

func (s *Store) PurgeAll() error

PurgeAll removes the snapshots in this dedicated cache directory and fences all writes already in flight. It is used by the explicit CLI sign-out.

func (*Store) Save

func (s *Store) Save(account string, generation, revision uint64, data Snapshot) error

Jump to

Keyboard shortcuts

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