pkgcache

Cache CRAN-like metadata and package files

lifecycle CRAN status R build status Coverage status

Metadata and package cache for CRAN-like repositories. This is a utility package to be used by package management tools that want to take advantage of caching.

Installation

You can install the released version of pkgcache from CRAN with:

install.packages("pkgcache")

Metadata cache

meta_cache_list() lists all packages in the metadata cache. It includes Bioconductor package, and all versions (i.e. both binary and source) of the packages for the current platform and R version.

library(pkgcache)
meta_cache_list()
#> # A tibble: 35,272 x 33
#>    package title version depends suggests built imports archs repodir
#>    <chr>   <chr> <chr>   <chr>   <chr>    <chr> <chr>   <chr> <chr>  
#>  1 A3      "Acc… 1.0.0   R (>= … randomF… R 3.… <NA>    <NA>  bin/ma…
#>  2 aaSEA   Amin… 1.1.0   R(>= 3… knitr, … R 3.… "DT(>=… <NA>  bin/ma…
#>  3 ABACUS  "App… 1.0.0   R (>= … rmarkdo… R 3.… ggplot… <NA>  bin/ma…
#>  4 abbyyR  Acce… 0.5.5   R (>= … testtha… R 3.… httr, … <NA>  bin/ma…
#>  5 abc.da… Data… 1.0     R (>= … <NA>     R 3.… <NA>    <NA>  bin/ma…
#>  6 ABC.RAP Arra… 0.9.0   R (>= … knitr, … R 3.… graphi… <NA>  bin/ma…
#>  7 abc     Tool… 2.1     R (>= … <NA>     R 3.… <NA>    <NA>  bin/ma…
#>  8 abcADM  Fit … 1.0     <NA>    <NA>     R 3.… Rcpp (… abcA… bin/ma…
#>  9 ABCana… Comp… 1.2.1   R (>= … <NA>     R 3.… plotrix <NA>  bin/ma…
#> 10 abcdeF… "ABC… 0.4     Rglpk,… LIM,syb… R 3.… <NA>    <NA>  bin/ma…
#> # … with 35,262 more rows, and 24 more variables: platform <chr>,
#> #   rversion <chr>, needscompilation <chr>, priority <chr>, ref <chr>,
#> #   type <chr>, direct <lgl>, status <chr>, target <chr>, mirror <chr>,
#> #   sources <list>, filesize <int>, sha256 <chr>, sysreqs <chr>,
#> #   published <dttm>, deps <list>, license <chr>, md5sum <chr>,
#> #   linkingto <chr>, enhances <chr>, license_restricts_use <chr>,
#> #   os_type <chr>, license_is_foss <chr>, path <chr>

meta_cache_deps() and meta_cache_revdeps() can be used to look up dependencies and reverse dependencies.

The metadata is updated automatically if it is older than seven days, and it can also be updated manually with meta_cache_update().

See the cranlike_metadata_cache R6 class for a lower level API, and more control.

Package cache

Package management tools may use the pkg_cache_* functions and in particular the package_cache class, to make use of local caching of package files.

The pkg_cache_* API is high level, and uses a user level cache:

pkg_cache_summary()
#> $cachepath
#> [1] "/Users/gaborcsardi/Library/Caches/R-pkg/pkg"
#> 
#> $files
#> [1] 677
#> 
#> $size
#> [1] 608180353
pkg_cache_list()
#> # A tibble: 677 x 10
#>    fullpath path  package url   etag  sha256 built version platform
#>    <chr>    <chr> <chr>   <chr> <chr> <chr>  <int> <chr>   <chr>   
#>  1 /Users/… src/… crayon  <NA>  <NA>  84be6…     0 <NA>    <NA>    
#>  2 /Users/… bin/… proces… http… "\"3… ce84a…    NA 3.4.1   macos   
#>  3 /Users/… bin/… R6      http… "\"d… 4cfe3…    NA 2.4.0   macos   
#>  4 /Users/… bin/… ps      http… "\"3… 63add…    NA 1.3.0   macos   
#>  5 /Users/… src/… callr   <NA>  <NA>  df85a…     0 <NA>    <NA>    
#>  6 /Users/… bin/… callr   http… "\"5… 1a5e3…    NA 3.3.1   macos   
#>  7 /Users/… bin/… assert… http… "\"d… 103f9…    NA 0.2.1   macos   
#>  8 /Users/… bin/… backpo… http… "\"d… 344bb…    NA 1.1.4   macos   
#>  9 /Users/… bin/… crayon  http… "\"b… 2ac4f…    NA 1.3.4   macos   
#> 10 /Users/… bin/… desc    http… "\"4… 196ce…    NA 1.2.0   macos   
#> # … with 667 more rows, and 1 more variable: vignettes <chr>
pkg_cache_find(package = "dplyr")
#> # A tibble: 4 x 10
#>   fullpath path  package url   etag  sha256 built version platform
#>   <chr>    <chr> <chr>   <chr> <chr> <chr>  <int> <chr>   <chr>   
#> 1 /Users/… bin/… dplyr   http… "\"6… e2594…    NA 0.8.3   macos   
#> 2 /Users/… src/… dplyr   <NA>  <NA>  134b1…     0 <NA>    <NA>    
#> 3 /Users/… src/… dplyr   <NA>  <NA>  b357f…     0 <NA>    <NA>    
#> 4 /Users/… src/… dplyr   <NA>  <NA>  81767…     0 <NA>    <NA>    
#> # … with 1 more variable: vignettes <chr>

pkg_cache_add_file() can be used to add a file, pkg_cache_delete_files() to remove files, pkg_cache_get_files() to copy files out of the cache.

The package_cache class provides a finer API.

Bioconductor support

Both the metadata cache and the package cache support Bioconductor by default, automatically. See the BioC_mirror option and the R_BIOC_MIRROR and R_BIOC_VERSION environment variables below to configure pkgcache’s Bioconductor support.

Package Options

Package environment variables

Using pkgcache in CRAN packages

If you use pkgcache in your CRAN package, please make sure that

This is to make sure that pkgcache does not modify the user’s files while running R CMD check.

Code of Conduct

Please note that the ‘pkgcache’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

MIT (c) RStudio Inc