depcache-package: Cache R Expressions, Taking Their Dependencies into Account

depcache-packageR Documentation

Cache R Expressions, Taking Their Dependencies into Account

Description

Hash an expression with its dependencies and store its value, reloading it from a file as long as both the expression and its dependencies stay the same.

Details

The functions in this package take an expression, walk its code to find its dependencies and calculate a hash of them. If a corresponding file already exists, it is loaded; otherwise, the expression is evaluated and its value is saved in the file. Optionally, this check may be performed every time a variable is accessed.

By default, a subdirectory of the current directory is used to store the cache files.

Index: This package was not yet installed at build time.

Author(s)

Ivan Krylov

References

FNV-1a hash: http://www.isthe.com/chongo/tech/comp/fnv/

See Also

cache, %<-%

Examples

  
  a <- 1
  # will evaluate expression
  cache({ message('evaluating expression'); a + 1 }) # 2
  # will reuse cached value
  x %<-% { message('evaluating expression'); a + 1 } # 2
  x
  a <- 2
  # will recalculate the value
  x # 3
  

depcache documentation built on June 21, 2022, 9:06 a.m.