licence_audit/notice_cache
Namespaced cache for notice/licence materials.
Caches extracted files and licence text between runs. notice_resolve
supplies immutable content keys and mutable tag keys, and bypasses this
storage for mutable path dependencies. Tag results expire after 24 hours.
Returned storage errors let the resolver read live and produce deferred
warnings returned with each operation. Use --no-cache to bypass the
cache.
Types
Opaque cache handle. Holds a store when caching is enabled and available.
pub opaque type Cache
Configures how the cache behaves for a given run.
pub type Mode {
Enabled(path: option.Option(String))
Disabled
}
Constructors
-
Enabled(path: option.Option(String))Cache enabled;
pathselects the application root whenSome. -
DisabledBypass the cache entirely (no read, no write, no file opened).
Values
pub fn close(cache: Cache) -> option.Option(String)
Return the warning from opening the cache.
pub fn get_files(
cache: Cache,
key: String,
) -> #(
Result(List(notice.NoticeFile), Nil),
option.Option(String),
)
Read a cached list of notice files stored under a namespaced key. Returns
Error(Nil) on a miss, when the cache is disabled, or when the stored value
no longer decodes (a corrupt entry is a miss so the caller refetches).
pub fn get_text(
cache: Cache,
key: String,
) -> #(Result(String, Nil), option.Option(String))
Read a cached plain-text value (e.g. a resolved commit SHA or canonical SPDX
text) stored under key. Blank values and tag results without a fresh
timestamp are treated as misses. Reads do not extend a tag’s lifetime.
pub fn open(mode: Mode) -> Cache
Open a cache according to mode.
Returns no error value. If the cache path cannot be prepared, the returned
Cache bypasses storage and includes a deferred warning accessible via
close.
pub fn put_files(
cache: Cache,
key: String,
files: List(notice.NoticeFile),
) -> option.Option(String)
Best-effort write of notice files under key, returning any storage warning.
pub fn put_text(
cache: Cache,
key: String,
value: String,
) -> option.Option(String)
Best-effort write of a plain-text value under key, timestamping tag results.