Skip to main content

Crate sui_cache

Crate sui_cache 

Source
Expand description

Built-in binary cache server and push pipeline for sui.

Replaces Attic, Cachix, and nix-serve with a single integrated component. Implements the standard Nix binary cache HTTP protocol (narinfo + NAR).

§Architecture

  • sui_castore — pluggable storage backends (shared with sui-registry); re-exported from here for backward compatibility.
  • server — axum HTTP server implementing the cache protocol
  • signing — ed25519 key management and narinfo signing
  • push — pipeline to push store paths to the cache
  • gc — garbage collection of unreferenced cache entries
  • config — cache configuration types (CacheConfig; BackendConfig is in sui-castore)

Re-exports§

pub use config::CACHE_TIER_ENV;
pub use config::CacheConfig;
pub use gc::GcResult;
pub use push::LevelOutOfRange;
pub use push::NarCodec;
pub use push::PushResult;
pub use push::XzLevel;
pub use push::ZstdLevel;
pub use server::AppState;
pub use server::build_router;
pub use server::serve;
pub use signing::CacheSigner;
pub use signing::verify_narinfo_signature;

Modules§

config
Cache configuration types.
gc
Garbage collection for the binary cache.
push
Push pipeline — build output to NAR to sign to upload.
server
Axum HTTP server implementing the Nix binary cache protocol.
signing
Ed25519 signing for narinfo metadata.

Structs§

BytesNarSource
A NarSource over bytes already in memory.
FileNarSource
A NarSource over a file on disk.
LocalStorage
Filesystem-backed binary cache storage.
MemNarRefIndex
In-memory NarRefIndex — the reference semantics, and what every test double uses.
NarRefKey
The typed key of one reverse edge: “hash’s narinfo advertises nar_path”.
NarRefScan
The typed key prefix enumerating every edge into one NAR.
PgStorageBackend
L2 durable cache tier: content-addressed key → value over Postgres, shared across pods, survives a roll.
RedisBackend
L1 hot cache: content-addressed key → value, sub-ms hits, TTL/eviction-aware.
S3Storage
S3-compatible object storage backend.
SpooledNarSource
A NarSource over a spool file, deleted when the source is dropped.
StorageIndex
Ephemeral metadata index backed by redb.
TieredBackend
Three-tier read-through / write-through cache resolver.

Enums§

BackendConfig
Storage backend selection.
CacheError
CacheError is now sui_castore::StoreError (same variants, same derives). This type alias preserves every existing sui_cache::CacheError use site. Error type for content-addressed store operations.
ExpandEnvError
A ${VAR} token referenced an environment variable that is not set.
NarResidency
What a backend’s NAR path costs in resident memory.
PgTable
The three logical tables the cache tier keeps: narinfo text, NAR blobs, and the reverse edges between them.
TieredTier
The honest self-description of what TieredBackend has been proven against — asserted by the honest gate so a claim cannot be silently rounded up.
WritePolicy
How a put propagates across the tiers. See the module docs for the full contract; every policy persists both durable tiers before returning.

Constants§

DEFAULT_INGEST_MEMORY_CAP
Default cap for the in-memory ingest fallback — see spool_or_buffer.
NAR_CHUNK_BYTES
The bounded chunk size every streaming NAR path moves bytes in.
NAR_REF_PREFIX
Key-space prefix owning every reverse edge.
TIERED_BACKEND_TIER
The shipped tier of TieredBackend. Asserted by the honest gate; bumping it to LiveClusterProven without a live integration test is a build-failing round-up.

Traits§

NarRefIndex
The reverse index of a single StorageBackend.
NarSource
A re-openable NAR byte source.
PgCacheConn
The minimal typed Postgres row-verb surface PgStorageBackend depends on.
RedisConn
The minimal async redis verb surface RedisBackend depends on.
StorageBackend
Abstraction over binary cache storage.

Functions§

advertised_nar_url
The NAR path a stored narinfo advertises, if it advertises an addressable one.
advertised_url_line
The raw URL: field of a narinfo, unjudged.
build_backend
Config-select factory: build the concrete StorageBackend a BackendConfig names.
bytes_stream
Yield in-memory bytes as bounded chunks (zero-copy slices of one allocation).
collect_nar
Drain a NarStream into one buffer.
empty_stream
A stream that yields nothing.
expand_env_vars
Expand ${VAR} tokens in text against the process environment.
file_stream
Read an open file as bounded chunks. O(chunk) resident.
is_addressable_nar_path
Whether a narinfo’s URL: is a NAR path this store can safely address.
is_servable_narinfo
Is this narinfo text usable by a Nix client at all?
referrer_of
Recover the referring store-path hash from a scanned edge key.
spool_or_buffer
Turn a one-shot byte stream into a re-openable NarSource, bounded either way.
whole_value_stream
A stream that yields exactly one chunk — the whole value.

Type Aliases§

NarStream
A NAR byte stream — bounded chunks, consumed exactly once.