cache

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JellyfinItemsCachePrefix = "jellyfin-items-"
	SonarrItemsCachePrefix   = "sonarr-items-"
	SonarrTagsCachePrefix    = "sonarr-tags-"
	RadarrItemsCachePrefix   = "radarr-items-"
	RadarrTagsCachePrefix    = "radarr-tags-"
)

Cache key prefixes.

Variables

This section is empty.

Functions

This section is empty.

Types

type EngineCache

type EngineCache struct {
	SonarrTagsCache *PrefixedCache[TagMap]
	RadarrTagsCache *PrefixedCache[TagMap]
}

func NewEngineCache

func NewEngineCache(cfg *config.CacheConfig) (*EngineCache, error)

func (*EngineCache) ClearAll

func (e *EngineCache) ClearAll(ctx context.Context)

func (*EngineCache) GetStats

func (e *EngineCache) GetStats() []*Stats

type ImageCache

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

func NewImageCache

func NewImageCache(cacheDir string, db database.MediaDB) *ImageCache

NewImageCache creates a new image cache manager with scaling options.

func (*ImageCache) Clear

func (ic *ImageCache) Clear(ctx context.Context) error

Clear clears the image cache directory without removing the directory itself.

func (*ImageCache) GetCachedImagePath

func (ic *ImageCache) GetCachedImagePath(ctx context.Context, imageURL string) (string, error)

GetCachedImagePath returns the local path for an image, downloading it if necessary.

func (*ImageCache) GetCachedImageURL

func (ic *ImageCache) GetCachedImageURL(imageURL string) string

GetCachedImageURL returns a local URL for an image, downloading it if necessary.

func (*ImageCache) ServeImage

func (ic *ImageCache) ServeImage(ctx context.Context, mediaID uint, w http.ResponseWriter, r *http.Request) error

ServeImage serves a cached image or downloads it if not cached.

type JellyfinItem

type JellyfinItem struct {
	jellyfin.BaseItemDto
	ParentLibraryName string `json:"parentLibraryName,omitempty"`
}

JellyfinItem represents a Jellyfin media item with its library context.

type JellyfinItemsData

type JellyfinItemsData struct {
	Items []JellyfinItem `json:"items"`
}

JellyfinItemsData contains cached Jellyfin items.

type PrefixedCache

type PrefixedCache[T any] struct {
	// contains filtered or unexported fields
}

PrefixedCache wraps a cache.Cache and adds a prefix to all keys.

func NewPrefixedCache

func NewPrefixedCache[T any](cache *cache.Cache[any], cacheType config.CacheType, prefix string) *PrefixedCache[T]

NewPrefixedCache creates a new prefixed cache wrapper.

func (*PrefixedCache[T]) Clear

func (p *PrefixedCache[T]) Clear(ctx context.Context) error

Clear removes all values from the cache.

func (*PrefixedCache[T]) Delete

func (p *PrefixedCache[T]) Delete(ctx context.Context, key any) error

Delete removes a value from the cache with the prefixed key.

func (*PrefixedCache[T]) Get

func (p *PrefixedCache[T]) Get(ctx context.Context, key any) (T, error)

Get retrieves a value from the cache with the prefixed key.

func (*PrefixedCache[T]) GetStats

func (p *PrefixedCache[T]) GetStats() *codec.Stats

GetStats returns the cache statistics.

func (*PrefixedCache[T]) GetType

func (p *PrefixedCache[T]) GetType() string

GetType returns the cache type.

func (*PrefixedCache[T]) Invalidate

func (p *PrefixedCache[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error

Invalidate removes values from the cache matching the prefixed pattern.

func (*PrefixedCache[T]) Set

func (p *PrefixedCache[T]) Set(ctx context.Context, key any, object T, options ...store.Option) error

Set stores a value in the cache with the prefixed key.

type Stats

type Stats struct {
	*codec.Stats
	CacheName string `json:"cacheName"`
}

type TagMap

type TagMap map[int32]string

Jump to

Keyboard shortcuts

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