cache

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 12 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BookmarksKey added in v0.9.0

func BookmarksKey(itemID string) string

BookmarksKey is the key of the bookmarks of a library item.

func ItemKey added in v0.9.0

func ItemKey(itemID string) string

ItemKey is the key of a library item.

func PersonalizedKey added in v0.9.0

func PersonalizedKey(libraryID string) string

PersonalizedKey is the key of the home shelves of a library.

func SearchSnapshotKey added in v0.9.0

func SearchSnapshotKey(libraryID string) string

SearchSnapshotKey is the key of the search snapshot of a library, which the search cache writes.

func SeriesContentsKey added in v0.9.0

func SeriesContentsKey(seriesID string) string

SeriesContentsKey is the key of the contents of a series.

Types

type Client

type Client struct {
	*abs.Client

	OnInvalidate func()
	// contains filtered or unexported fields
}

Client is a transparent caching wrapper around abs.Client.

func NewClient

func NewClient(inner *abs.Client, store *Store) *Client

NewClient creates a caching wrapper around the given ABS client.

func (*Client) DeleteEpisode added in v0.4.0

func (c *Client) DeleteEpisode(ctx context.Context, podcastID string, episodeID string, hardDelete bool) error

DeleteEpisode deletes a podcast episode from the API and invalidates the caches.

func (*Client) DeleteItem added in v0.4.0

func (c *Client) DeleteItem(ctx context.Context, itemID string, hardDelete bool) error

DeleteItem deletes a library item from the API and invalidates the caches.

func (*Client) FilterAudioLibraries

func (c *Client) FilterAudioLibraries(ctx context.Context, libs []abs.Library) []abs.Library

FilterAudioLibraries filters audio libraries using cache or fetches from the API.

func (*Client) GetBookmarks

func (c *Client) GetBookmarks(ctx context.Context, itemID string) ([]abs.Bookmark, error)

GetBookmarks returns bookmarks from cache or fetches from the API.

func (*Client) GetLibraries

func (c *Client) GetLibraries(ctx context.Context) ([]abs.Library, error)

GetLibraries returns libraries from cache or fetches from the API.

func (*Client) GetLibraryItem

func (c *Client) GetLibraryItem(ctx context.Context, itemID string) (*abs.LibraryItem, error)

GetLibraryItem returns a single library item from cache or fetches from the API.

func (*Client) GetLibraryItems

func (c *Client) GetLibraryItems(ctx context.Context, libraryID string, page, limit int) (*abs.LibraryItemsResponse, error)

GetLibraryItems returns a paginated list of library items from cache or fetches from the API. The response has the requested page and limit.

func (*Client) GetLibrarySeries

func (c *Client) GetLibrarySeries(ctx context.Context, libraryID string, page, limit int) (*abs.LibrarySeriesResponse, error)

GetLibrarySeries returns a paginated list of series from cache or fetches from the API. The response has the requested page and limit.

func (*Client) GetPersonalized

func (c *Client) GetPersonalized(ctx context.Context, libraryID string) ([]abs.PersonalizedResponse, error)

GetPersonalized returns personalized shelves from cache or fetches from the API.

func (*Client) GetRecentEpisodes

func (c *Client) GetRecentEpisodes(ctx context.Context, libraryID string, limit int) ([]abs.LibraryItem, error)

GetRecentEpisodes returns recent podcast episodes from cache or fetches from the API.

func (*Client) GetSeriesContents

func (c *Client) GetSeriesContents(ctx context.Context, libraryID, seriesID string) (*abs.SeriesContents, error)

GetSeriesContents returns series contents from cache or fetches from the API.

func (*Client) Invalidate added in v0.11.0

func (c *Client) Invalidate()

Invalidate wipes the persistent cache after a change on the server, and tells the in-memory caches (the search cache) to drop their snapshots. A change is rare, so it clears each key.

func (*Client) ScanLibrary added in v0.10.0

func (c *Client) ScanLibrary(ctx context.Context, libraryID string) error

ScanLibrary scans a library on the server, waits for the end of the scan, and invalidates the caches.

func (*Client) UpdateLibraryItemMedia added in v0.4.0

func (c *Client) UpdateLibraryItemMedia(ctx context.Context, itemID string, req abs.UpdateMediaRequest) (*abs.LibraryItem, error)

UpdateLibraryItemMedia updates media metadata and invalidates the caches.

func (*Client) UpdatePodcastEpisode added in v0.4.0

func (c *Client) UpdatePodcastEpisode(ctx context.Context, itemID, episodeID string, req abs.UpdatePodcastEpisodeRequest) (*abs.LibraryItem, error)

UpdatePodcastEpisode updates episode metadata and invalidates the caches.

type Store

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

Store provides generic get/put/delete/evict operations over a SQLite table.

func NewStore

func NewStore(db *db.Store) *Store

NewStore creates a cache backed by the given database.

func (*Store) ClearAll added in v0.4.0

func (s *Store) ClearAll() error

ClearAll removes all cache entries.

func (*Store) Delete

func (s *Store) Delete(key string) error

Delete removes the entry for key.

func (*Store) EvictExpired

func (s *Store) EvictExpired() error

EvictExpired removes all expired entries.

func (*Store) Get

func (s *Store) Get(key string, dest any) (bool, error)

Get attempts to retrieve and decode the value for key into dest. Returns (true, nil) on hit, (false, nil) on miss, and (false, err) if the database or the decode fails.

func (*Store) Put

func (s *Store) Put(key string, value any, ttl time.Duration) error

Put gob-encodes value and stores it with the given TTL.

Jump to

Keyboard shortcuts

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