Skip to contents

Returns a one-row table with the cache settings, the number of times a saved result was used (a hit) or not used (a miss) in this R session, and a summary of the files in the cache folder.

Usage

cacs_get_cache_state()

Value

A tibble with one row and these columns:

enabled

Whether the cache is on (see cacs_set_cache()). This column does not show a kind of saved result that is turned off on its own.

cache_dir

The path of the cache folder, as returned by cacs_cache_dir().

namespace_mode

"test" in test mode, which is on, for example, while testthat runs tests and no cache folder is set with the option catchmentACS.cache_dir or the environment variable CACS_CACHE_DIR. American Community Survey (ACS) data are then kept in the subfolder acs_test instead of acs. Otherwise "production".

fingerprint_algorithm

The checksum method of the checksum files, "sha256" (see cacs_cache_dir()).

counters

A list holding a tibble with one row for each kind of saved result (isochrone, acs, and intersect; see cacs_clear_cache()). Its columns are namespace, hit, miss, and hit_rate, which is hit / (hit + miss) or NaN before the first lookup. Its acs row adds up the subfolders acs and acs_test.

hits, misses

Lists each holding a named integer vector of the same counts for each subfolder: isochrone, acs, acs_test, and intersect.

status

A list holding the table returned by cacs_cache_status().

session_started_at

The time, in UTC, at which the package was loaded in this session.

Hits and misses

Each time cacs_isochrone(), cacs_acs_prefetch(), or cacs_intersect_weight() looks for a saved result, the lookup counts as a hit if the saved result is used and as a miss if the result is computed or downloaded instead. A miss happens when nothing is saved for the inputs or the saved result fails its checksum check (see cacs_cache_dir()), and, for the first two functions, when the cache is off. cacs_intersect_weight() does not look while the cache is off, and cacs_acs_prefetch() does not look with force_refresh = TRUE. Lookups in a folder given in a cache_dir argument are counted too. The counts start when the package is loaded, and cacs_clear_cache() sets them back to zero for the subfolders it clears.

See also

Examples

cacs_get_cache_state()
#> # A tibble: 1 × 9
#>   enabled cache_dir   namespace_mode fingerprint_algorithm counters hits  misses
#>   <lgl>   <chr>       <chr>          <chr>                 <list>   <lis> <list>
#> 1 TRUE    /tmp/RtmpM… production     sha256                <tibble> <int> <int> 
#> # ℹ 2 more variables: status <list>, session_started_at <dttm>

# The numbers of hits and misses for each kind of saved result
cacs_get_cache_state()$counters[[1]]
#> # A tibble: 3 × 4
#>   namespace   hit  miss hit_rate
#>   <chr>     <int> <int>    <dbl>
#> 1 isochrone     0     0      NaN
#> 2 acs           0     0      NaN
#> 3 intersect     0     0      NaN