Skip to contents

Deletes all objects from a package's user-cache pins board that exceed a certain max_age. If board is pkg_versioned, additionally deletes all user-cache pins boards belonging to versions of the package other than the currently installed one.

Usage

clear_cache(board, max_age = "1 day")

Arguments

board

Package's user-cache pins board.

max_age

Age above which cached objects will be deleted. A valid lubridate duration. Defaults to 1 day (24 hours).

Value

board, invisibly.

Details

This function could be called on package load/unload, for example.

See also

Other package cache management functions: board(), ls_cache(), path_cache(), purge_cache(), purge_caches()

Examples

if (FALSE) { # \dontrun{
# delete all cached results that are older than 7 days at once on package load:
.onLoad <- function(libname, pkgname) {
  pkgpins::clear_cache(board = pkgpins::board(pkg = pkgname),
                       max_age = "7 days")
}} # }