bsdkrun/cache

Cached guest directories.

Entries are keyed, so a rebuild can pick up where the last one left off:

import bsdkrun/cache

let assert Ok(hit) = cache.restore("web", "deps-abc", None, ["deps-"])
case hit.restored {
  False -> {
    let assert Ok(_) = sandbox.exec("web", ["npm", "ci"])
    cache.save("web", "/app/node_modules", "deps-abc", cache.Gzip, False)
  }
  True -> Ok(Nil)
}

Where entries live — host disk or S3 — is host configuration, not an SDK concern: set BSDKRUN_CACHE_BACKEND / BSDKRUN_CACHE_S3_*, or write ~/.config/bsdkrun/cache.toml.

Types

An archive format a cache entry can be stored in.

pub type Compression {
  Gzip
  Zstd
  Estargz
  Uncompressed
}

Constructors

  • Gzip
  • Zstd
  • Estargz
  • Uncompressed

Values

pub fn list() -> Result(List(types.CacheEntry), error.Error)

Every stored cache entry, newest first.

pub fn remove(
  keys: List(String),
  all: Bool,
) -> Result(Nil, error.Error)

Remove entries by key, or every one of them with all.

pub fn restore(
  id: String,
  key: String,
  path: option.Option(String),
  restore_keys: List(String),
) -> Result(types.RestoreResult, error.Error)

Restore a stored tree. path defaults to where the entry was saved from; restore_keys are prefixes tried in order when key misses.

pub fn save(
  id: String,
  path: String,
  key: String,
  compression: Compression,
  force: Bool,
) -> Result(types.CacheEntry, error.Error)

Archive the guest directory at path under key.

Search Document