Documentation
¶
Index ¶
- Variables
- func BookmarksKey(itemID string) string
- func CachedOnly(ctx context.Context) context.Context
- func ItemKey(itemID string) string
- func PersonalizedKey(libraryID string) string
- func SearchSnapshotKey(libraryID string) string
- func SeriesContentsKey(seriesID string) string
- type Client
- func (c *Client) DeleteEpisode(ctx context.Context, podcastID string, episodeID string, hardDelete bool) error
- func (c *Client) DeleteItem(ctx context.Context, itemID string, hardDelete bool) error
- func (c *Client) FilterAudioLibraries(ctx context.Context, libs []abs.Library) []abs.Library
- func (c *Client) GetBookmarks(ctx context.Context, itemID string) ([]abs.Bookmark, error)
- func (c *Client) GetLibraries(ctx context.Context) ([]abs.Library, error)
- func (c *Client) GetLibraryItem(ctx context.Context, itemID string) (*abs.LibraryItem, error)
- func (c *Client) GetLibraryItems(ctx context.Context, libraryID string, page, limit int) (*abs.LibraryItemsResponse, error)
- func (c *Client) GetLibrarySeries(ctx context.Context, libraryID string, page, limit int) (*abs.LibrarySeriesResponse, error)
- func (c *Client) GetPersonalized(ctx context.Context, libraryID string) ([]abs.PersonalizedResponse, error)
- func (c *Client) GetRecentEpisodes(ctx context.Context, libraryID string, limit int) ([]abs.LibraryItem, error)
- func (c *Client) GetSeriesContents(ctx context.Context, libraryID, seriesID string) (*abs.SeriesContents, error)
- func (c *Client) Invalidate()
- func (c *Client) ScanLibrary(ctx context.Context, libraryID string) error
- func (c *Client) UpdateLibraryItemMedia(ctx context.Context, itemID string, req abs.UpdateMediaRequest) (*abs.LibraryItem, error)
- func (c *Client) UpdatePodcastEpisode(ctx context.Context, itemID, episodeID string, ...) (*abs.LibraryItem, error)
- type Store
- func (s *Store) ClearAll() error
- func (s *Store) Delete(key string) error
- func (s *Store) EvictExpired() error
- func (s *Store) Expire(key string) error
- func (s *Store) Get(key string, dest any) (bool, error)
- func (s *Store) GetStale(key string, dest any) (bool, error)
- func (s *Store) Put(key string, value any, ttl time.Duration) error
Constants ¶
This section is empty.
Variables ¶
var ErrNotCached = errors.New("not in the cache")
ErrNotCached is the error of a read with a CachedOnly context that finds no entry.
Functions ¶
func BookmarksKey ¶ added in v0.9.0
BookmarksKey is the key of the bookmarks of a library item.
func CachedOnly ¶ added in v0.12.0
CachedOnly returns a context for reads that answer only from the local cache, also from an expired entry, and send no request. A read that finds no entry returns ErrNotCached.
func PersonalizedKey ¶ added in v0.9.0
PersonalizedKey is the key of the home shelves of a library.
func SearchSnapshotKey ¶ added in v0.9.0
SearchSnapshotKey is the key of the search snapshot of a library, which the search cache writes.
func SeriesContentsKey ¶ added in v0.9.0
SeriesContentsKey is the key of the contents of a series.
Types ¶
type Client ¶
Client is a transparent caching wrapper around 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
DeleteItem deletes a library item from the API and invalidates the caches.
func (*Client) FilterAudioLibraries ¶
FilterAudioLibraries filters audio libraries using cache or fetches from the API.
func (*Client) GetBookmarks ¶
GetBookmarks returns bookmarks from cache or fetches from the API.
func (*Client) GetLibraries ¶
GetLibraries returns libraries from cache or fetches from the API.
func (*Client) GetLibraryItem ¶
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
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 (*Store) EvictExpired ¶
EvictExpired removes the entries that expired more than keepExpired ago.
func (*Store) Expire ¶ added in v0.12.0
Expire makes a fresh entry for key expired now, so that Get misses it and GetStale still reads it.
func (*Store) Get ¶
Get attempts to retrieve and decode the value for key into dest. An expired entry is a miss. Returns (true, nil) on hit, (false, nil) on miss, and (false, err) if the database or the decode fails.