Skip to contents

Removes every entry. Which of two things happens underneath depends on whether the cache settings have changed since the store was built:

Usage

cache_reset()

Value

NULL, invisibly.

Details

Settings unchanged

The existing store is cleared in place, so a reference taken from cache() earlier stays valid and keeps pointing at the live cache. This is the ordinary case.

Settings changed

The store is dropped so the next cache() builds one from the new settings. Tests rely on this after pointing BIOHTTP_CACHE_DIR at a fresh tempdir or toggling BIOHTTP_CACHE_DISK.

The in-place branch exists because dropping unconditionally silently orphans any held reference: writes through it go somewhere nothing else can see, and the only symptom is a hit rate quietly falling to zero. A reference held across a genuine settings change is still orphaned, but nothing changes cache settings mid-run except a test suite, and those do not hold references.

Examples

held <- cache()
cache_reset()
identical(held, cache())
#> [1] TRUE