Stores one value per provider against a fitted parameter map, for the lifetime of the R session. It exists so that packages building on BayesTools can avoid recomputing map-derived metadata without inventing their own storage inside fitted objects.

The cache is keyed by the map and by key, a value naming everything else the cached result was derived from. Whenever key stops being identical() to the stored one the value is recomputed, so a result that also depends on data or priors stays correct when those change. Passing a key that does not cover every input is the one way to use this incorrectly.

Entries never travel with a saved fit, and BayesTools discards every provider's entries whenever the map's own tables are replaced.

parameter_map_cache(map, provider, key, compute)

Arguments

map

a parameter map, as returned by parameter_map().

provider

name of the calling package.

key

a value identifying every input other than map that compute depends on. Compared with identical().

compute

a function of no arguments returning the value to cache.

Value

The cached or freshly computed value of compute().

See also