dlcache

package
v0.1.147 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: GPL-2.0, GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package dlcache provides a generic LRU download-data cache with heap-based eviction. Reusable by any provider that caches season-pack or download data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DownloadCache

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

DownloadCache is a thread-safe LRU cache for download data (e.g. season pack zip/rar contents). Evicts least-recently-used entries when the entry count exceeds maxEntries.

func New

func New(maxEntries int, maxItemSize int64) *DownloadCache

New creates a DownloadCache with the given limits.

func (*DownloadCache) Clear

func (dc *DownloadCache) Clear()

Clear removes all cached data and resets the saturation guard.

func (*DownloadCache) Get

func (dc *DownloadCache) Get(key string) ([]byte, bool)

Get retrieves cached data by key. Returns nil, false on miss.

func (*DownloadCache) Put

func (dc *DownloadCache) Put(key string, data []byte, onSaturated func()) bool

Put stores data under key. Returns false (without storing) if the data exceeds maxItemSize or the cache is full and cannot evict. The onSaturated callback is called at most once per Clear cycle when the cache refuses to store an entry.

Jump to

Keyboard shortcuts

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