Presubmit.Source.Cache (presubmit v0.2.2)

Copy Markdown View Source

The shared cache of extracted facts: a public ETS table keyed by {blob_oid, path}, so a range of commits parses each distinct file version once.

The table is created by whichever process needs it first and dies with that process; the next user recreates it. Every operation tolerates the table vanishing between a lookup and an insert, so the worst case is a miss. The table is bounded: it is emptied when it grows past the limit.

Summary

Functions

Drops every cached value.

The cached value for key, computing and caching it with compute on a miss.

The cached value for key, or :miss.

Caches value under key.

Functions

clear()

@spec clear() :: :ok

Drops every cached value.

fetch(key, compute)

@spec fetch(term(), (-> value)) :: value when value: term()

The cached value for key, computing and caching it with compute on a miss.

get(key)

@spec get(term()) :: {:ok, term()} | :miss

The cached value for key, or :miss.

put(key, value)

@spec put(term(), term()) :: :ok

Caches value under key.