Skip to main content

Module cache_budget

Module cache_budget 

Source
Expand description

The client cache budget driven by the connection class (SSoT: design/filesystem/client § Automatic cache management, and design/networking § Connection Classes).

Three pieces, each with one job:

  • ConnectionClassSource — the port a client samples its current ConnectionClass through. InMemoryConnectionClass is the deterministic adapter tests (and any caller that learns the class out of band, such as a mobile shell pushing OS callbacks) set by hand; DesktopConnectionClass is the desktop adapter, which classifies whatever PathSignals its probe can read and reports unmetered when it can tell nothing.
  • plan_for — the pure policy: a class and the user’s base budget in, a CachePlan (the retention byte budget plus whether bulk transfers defer) out.
  • CacheBudget — the orchestration that samples the port, re-plans when the class changes mid-session, and hands the planned budget to the eviction sweep (capsule_library::library::cache_sweep). The sweep is passed in as a closure so this module names no storage type; the sweep alone decides what is evictable, so pinned representations and device-owned originals survive every re-plan.

Structs§

CacheBudget
Keeps the cache within the budget the current connection class allows.
CachePlan
What the client does with its cache and bulk transfers on one connection class.
CacheSweepOutcome
What one CacheBudget::sweep did.
DesktopConnectionClass
The desktop class source. Desktop operating systems expose no portable metered or data-saver signal, so the default probe reads nothing and the source reports ConnectionClass::Unmetered: a wired or Wi-Fi desktop is the networking table’s “OS reports not expensive / not metered” case. A platform that can read real signals installs a probe with with_probe, and whatever it reports is classified by ConnectionClass::from_signals.
InMemoryConnectionClass
A deterministic, settable class source. Tests drive class changes through it; a platform shell that is told the class by OS callbacks can push them through it as well.

Constants§

DEFAULT_BASE_CACHE_BUDGET
The default base cache budget, 2 GiB: the reclaimable bytes an unmetered client retains before the sweep evicts. The user setting overrides it; other classes scale it through ConnectionClass::cache_retention_budget.

Traits§

ConnectionClassSource
The port a client samples its current connection class through.

Functions§

plan_for
The cache plan for class from the user’s base_budget_bytes. Pure.

Type Aliases§

PathProbe
Reads the OS path signals on desktop, or None when the OS exposes nothing usable.