R.cache/0000755000176200001440000000000014266276262011532 5ustar liggesusersR.cache/NAMESPACE0000644000176200001440000000461614043103161012734 0ustar liggesusers# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # IMPORTS # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - importFrom("R.methodsS3", "setMethodS3") importFrom("R.oo", "throw") ## Importing Class:es importFrom("R.oo", "Package") ## Importing generics importFrom("R.oo", "clearCache") ## Importing functions importFrom("R.oo", "attachLocally") importFrom("R.oo", "startupMessage") importFrom("R.oo", "trim") importFrom("R.utils", "cat") ## Multi-sources: R.utils, base importFrom("R.utils", "isAbsolutePath") importFrom("R.utils", "isDirectory") importFrom("R.utils", "isFile") importFrom("R.utils", "listDirectory") importFrom("R.utils", "mkdirs") importFrom("R.utils", "removeDirectory") importFrom("R.utils", "touchFile") importFrom("utils", "compareVersion") importFrom("utils", "packageVersion") importFrom("utils", "file_test") importFrom("utils", "menu") importFrom("digest", "digest") ## Manually adjusted ## Cannot import explicitly from 'base'; ## importFrom("base", "getOption") ## Multi-sources: R.utils, base ## Manual imports importFrom("R.utils", "Arguments") # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # EXPORTS # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Export all public methods, that is, those without a preceeding dot # in their names. export("R.cache") export("evalWithMemoization") export("addMemoization") export("memoizedCall") export("getCacheRootPath") export("setCacheRootPath") export("getCachePath") export("findCache") export("generateCache") export("readCacheHeader") export("loadCache") export("saveCache") export("getChecksum") export("clearCache") # Imported from R.oo # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # S3 METHOD DECLARATIONS # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # default S3method("addMemoization", "default") S3method("clearCache", "default") S3method("findCache", "default") S3method("generateCache", "default") S3method("getCachePath", "default") S3method("getCacheRootPath", "default") S3method("getChecksum", "default") S3method("loadCache", "default") S3method("memoizedCall", "default") S3method("readCacheHeader", "default") S3method("saveCache", "default") S3method("setCachePath", "default") S3method("setCacheRootPath", "default") S3method("setupCacheRootPath", "default") # Object S3method("getChecksum", "Object") R.cache/man/0000755000176200001440000000000013572460205012274 5ustar liggesusersR.cache/man/setCachePath.Rd0000644000176200001440000000171414266251111015115 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % setCachePath.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{setCachePath} \alias{setCachePath.default} \alias{setCachePath} \title{Sets the path to the file cache directory} \description{ Sets the path to the file cache directory. } \usage{ \method{setCachePath}{default}(dirs=NULL, path=NULL, ...) } \arguments{ \item{dirs}{A \code{\link[base]{character}} \code{\link[base]{vector}} constituting the path to the cache subdirectory of interest.} \item{path}{The path to override the path according to the \code{dirs} argument.} \item{...}{Not used.} } \value{ Returns nothing. } \author{Henrik Bengtsson} \seealso{ \code{\link{getCachePath}}(). } \keyword{programming} \keyword{IO} \keyword{internal} R.cache/man/loadCache.Rd0000644000176200001440000000566314266251111014433 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % loadCache.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{loadCache} \alias{loadCache.default} \alias{loadCache} \title{Loads data from file cache} \description{ Loads data from file cache, which is unique for an optional key object. } \usage{ \method{loadCache}{default}(key=NULL, sources=NULL, suffix=".Rcache", removeOldCache=TRUE, pathname=NULL, dirs=NULL, ..., onError=c("warning", "error", "message", "quiet", "print")) } \arguments{ \item{key}{An optional object from which a hexadecimal hash code will be generated and appended to the filename.} \item{sources}{Optional source objects. If the cache object has a timestamp older than one of the source objects, it will be ignored and removed.} \item{suffix}{A \code{\link[base]{character}} string to be appended to the end of the filename.} \item{removeOldCache}{If \code{\link[base:logical]{TRUE}} and the cache is older than the \code{sources}, the cache file is removed, otherwise not.} \item{pathname}{The pathname to the cache file. If specified, arguments \code{key} and \code{suffix} are ignored. Note that this is only needed in order to read a cache file for which the key is unknown, for instance, in order to investigate an unknown cache file.} \item{dirs}{A \code{\link[base]{character}} \code{\link[base]{vector}} constituting the path to the cache subdirectory (of the \emph{cache root directory} as returned by \code{\link{getCacheRootPath}}()) to be used. If \code{\link[base]{NULL}}, the path will be the cache root path.} \item{...}{Not used.} \item{onError}{A \code{\link[base]{character}} string specifying what the action is if an exception is thrown.} } \value{ Returns an \R object or \code{\link[base]{NULL}}, if cache does not exist. } \details{ The hash code calculated from the \code{key} object is a 32 characters long hexadecimal MD5 hash code. For more details, see \code{\link{getChecksum}}(). } \author{Henrik Bengtsson} \examples{ simulate <- function(mean, sd) { # 1. Try to load cached data, if already generated key <- list(mean, sd) data <- loadCache(key) if (!is.null(data)) { cat("Loaded cached data\n") return(data); } # 2. If not available, generate it. cat("Generating data from scratch...") data <- rnorm(1000, mean=mean, sd=sd) Sys.sleep(1) # Emulate slow algorithm cat("ok\n") saveCache(data, key=key, comment="simulate()") data; } data <- simulate(2.3, 3.0) data <- simulate(2.3, 3.5) data <- simulate(2.3, 3.0) # Will load cached data # Clean up file.remove(findCache(key=list(2.3,3.0))) file.remove(findCache(key=list(2.3,3.5))) } \seealso{ \code{\link{saveCache}}(). } \keyword{programming} \keyword{IO} R.cache/man/memoizedCall.Rd0000644000176200001440000000334014266251111015163 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % memoizedCall.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{memoizedCall} \alias{memoizedCall.default} \alias{memoizedCall} \title{Calls a function with memoization} \description{ Calls a function with memoization, that is, caches the results to be retrieved if the function is called again with the exact same arguments. } \usage{ \method{memoizedCall}{default}(what, ..., envir=parent.frame(), force=FALSE, sources=NULL, dirs=NULL) } \arguments{ \item{what}{The \code{\link[base]{function}} to be called, or a \code{\link[base]{character}} string specifying the name of the function to be called, cf. \code{\link[base]{do.call}}().} \item{...}{Arguments passed to the function.} \item{envir}{The \code{\link[base]{environment}} in which the function is evaluated.} \item{force}{If \code{\link[base:logical]{TRUE}}, any cached results are ignored, otherwise not.} \item{sources, dirs}{Optional arguments passed to \code{\link{loadCache}}() and \code{\link{saveCache}}().} } \value{ Returns the result of the function call. } \details{ If the \code{\link[base]{function}} returns \code{\link[base]{NULL}}, that particular function call is \emph{not} memoized. } \author{Henrik Bengtsson} \seealso{ Internally, \code{\link{loadCache}}() is used to load memoized results, if available. If not available, then \code{\link{do.call}}() is used to evaluate the function call, and \code{\link{saveCache}}() is used to save the results to cache. } \keyword{programming} \keyword{IO} R.cache/man/findCache.Rd0000644000176200001440000000173714266251111014432 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % findCache.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{findCache} \alias{findCache.default} \alias{findCache} \title{Locates a cache file} \description{ Locates a cache file from a key object. } \usage{ \method{findCache}{default}(key=NULL, ...) } \arguments{ \item{key}{An optional object from which a hexadecimal hash code will be generated and appended to the filename.} \item{...}{Additional argument passed to \code{\link{generateCache}}().} } \value{ Returns the pathname as a \code{\link[base]{character}}, or \code{\link[base]{NULL}} if the no cached data exists. } \author{Henrik Bengtsson} \seealso{ \code{\link{generateCache}}(). \code{\link{loadCache}}(). } \keyword{programming} \keyword{IO} \keyword{internal} R.cache/man/getCachePath.Rd0000644000176200001440000000254614266251111015105 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % getCachePath.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{getCachePath} \alias{getCachePath.default} \alias{getCachePath} \title{Gets the path to the file cache directory} \description{ Gets the path to the file cache directory. If missing, the directory is created. } \usage{ \method{getCachePath}{default}(dirs=NULL, path=NULL, rootPath=getCacheRootPath(), ...) } \arguments{ \item{dirs}{A \code{\link[base]{character}} \code{\link[base]{vector}} constituting the path to the cache subdirectory (of the \emph{cache root directory} as returned by \code{\link{getCacheRootPath}}()) to be used. If \code{\link[base]{NULL}}, the path will be the cache root path.} \item{path, rootPath}{(Advanced) \code{\link[base]{character}} strings specifying the explicit/default cache path and root cache path.} \item{...}{Not used.} } \value{ Returns the path as a \code{\link[base]{character}} string. If the user does not have write permissions to the path, then an error is thrown. } \author{Henrik Bengtsson} \seealso{ \code{\link{setCachePath}}. } \keyword{programming} \keyword{IO} \keyword{internal} R.cache/man/getCacheRootPath.Rd0000644000176200001440000000173114266251111015744 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % getCacheRootPath.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{getCacheRootPath} \alias{getCacheRootPath.default} \alias{getCacheRootPath} \title{Gets the root path to the file cache directory} \description{ Gets the root path to the file cache directory. } \usage{ \method{getCacheRootPath}{default}(defaultPath=NULL, ...) } \arguments{ \item{defaultPath}{The default path, if no user-specified directory has been given.} \item{...}{Not used.} } \value{ Returns the path as a \code{\link[base]{character}} string. } \examples{ print(getCacheRootPath()) } \author{Henrik Bengtsson} \seealso{ Too set the directory where cache files are stored, see \code{\link{setCacheRootPath}}(). } \keyword{programming} \keyword{IO} R.cache/man/saveCache.Rd0000644000176200001440000000465414266251111014451 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % saveCache.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{saveCache} \alias{saveCache.default} \alias{saveCache} \title{Saves data to file cache} \description{ Saves data to file cache, which is unique for an optional key object. } \usage{ \method{saveCache}{default}(object, key=NULL, sources=NULL, suffix=".Rcache", comment=NULL, pathname=NULL, dirs=NULL, compress=NULL, ...) } \arguments{ \item{object}{The object to be saved to file.} \item{key}{An optional object from which a hexadecimal hash code will be generated and appended to the filename.} \item{sources}{Source objects used for comparison of timestamps when cache is loaded later.} \item{suffix}{A \code{\link[base]{character}} string to be appended to the end of the filename.} \item{comment}{An optional \code{\link[base]{character}} string written in ASCII at the beginning of the file.} \item{pathname}{(Advanced) An optional \code{\link[base]{character}} string specifying the pathname to the cache file. If not specified (default), a unique one is automatically generated from arguments \code{key} and \code{suffix} among other things.} \item{dirs}{A \code{\link[base]{character}} \code{\link[base]{vector}} constituting the path to the cache subdirectory (of the \emph{cache root directory} as returned by \code{\link{getCacheRootPath}}()) to be used. If \code{\link[base]{NULL}}, the path will be the cache root path.} \item{compress}{If \code{\link[base:logical]{TRUE}}, the cache file will be saved using gzip compression, otherwise not.} \item{...}{Additional argument passed to \code{\link[base]{save}}().} } \value{ Returns (invisible) the pathname of the cache file. } \section{Compression}{ The \code{saveCache()} method saves a compressed cache file (with filename extension *.gz) if argument \code{compress} is \code{\link[base:logical]{TRUE}}. The \code{\link{loadCache}}() method locates (via \code{\link{findCache}}()) and loads such cache files as well. } \author{Henrik Bengtsson} \examples{\dontrun{For an example, see ?loadCache}} \seealso{ For more details on how the hash code is generated etc, \code{\link{loadCache}}(). } \keyword{programming} \keyword{IO} R.cache/man/Options_used_by_R.cache.Rd0000644000176200001440000000334014266251111017246 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % options.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{Options used by R.cache} \alias{Options used by R.cache} \title{Options used by R.cache} \description{ Below are all \R options specific to the \pkg{R.cache} package. \cr \emph{WARNING: Note that the names and the default values of these options may change in future versions of the package. Please use with care until further notice.} } \section{Options for controlling futures}{ \describe{ \item{\option{R.cache.compress}:}{ If \code{\link[base:logical]{TRUE}}, \code{\link{saveCache}}() will write compressed cache files, otherwise not. (Default: \code{\link[base:logical]{FALSE}}) } \item{\option{R.cache.enabled}:}{ If \code{\link[base:logical]{TRUE}}, \code{\link{loadCache}}() is reading from and \code{\link{saveCache}}() is writing to the cache, otherwise not. (Default: \code{\link[base:logical]{TRUE}}) } \item{\option{R.cache.rootPath}:}{ A \code{\link[base]{character}} string specifying the default cache root path. If not set, environment variable \env{R_CACHE_ROOTPATH} is considered. } \item{\option{R.cache.touchOnLoad}:}{ If \code{\link[base:logical]{TRUE}}, \code{\link{loadCache}}() will update the "last-modified" timestamp of the cache file (to the current time), otherwise not. (Default: \code{\link[base:logical]{FALSE}}) } } } \keyword{internal} \alias{R.cache.options} \keyword{documentation} \keyword{programming} \keyword{IO} R.cache/man/readCacheHeader.Rd0000644000176200001440000000241214266251111015525 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % readCacheHeader.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{readCacheHeader} \alias{readCacheHeader.default} \alias{readCacheHeader} \title{Loads data from file cache} \description{ Loads data from file cache, which is unique for an optional key object. } \usage{ \method{readCacheHeader}{default}(file, ...) } \arguments{ \item{file}{A filename or a \code{\link[base:connections]{connection}}.} \item{...}{Not used.} } \value{ Returns a named \code{\link[base]{list}} structure with element \code{identifier}, \code{version}, \code{comment} (optional), \code{sources} (optional), and \code{timestamp}. } \author{Henrik Bengtsson} \examples{ data <- 1:120 key <- list(some=1, vari=2, ables=3) saveCache(key=key, data, comment="A simple example of a cached object.") header <- readCacheHeader(findCache(key=key)) print(header) # Clean up file.remove(findCache(key=key)) } \seealso{ \code{\link{findCache}}(). \code{\link{loadCache}}(). \code{\link{saveCache}}(). } \keyword{programming} \keyword{IO} \keyword{internal} R.cache/man/evalWithMemoization.Rd0000644000176200001440000000561614266251111016565 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % evalWithMemoization.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{evalWithMemoization} \alias{evalWithMemoization} \title{Evaluates an R expression with memoization} \description{ Evaluates an R expression with memoization such that the same objects are assigned to the current environment and the same result is returned, if any. } \usage{ evalWithMemoization(expr, key=NULL, ..., envir=parent.frame(), drop=c("srcref", "srcfile", "wholeSrcref"), force=FALSE) } \arguments{ \item{expr}{The \code{\link[base]{expression}} to be evaluated.} \item{key}{Additional objects to uniquely identify the evaluation.} \item{...}{Additional arguments passed to \code{\link{loadCache}}() and \code{\link{saveCache}}().} \item{envir}{The \code{\link[base]{environment}} in which the expression should be evaluated.} \item{drop}{\code{\link[base]{character}} vector of \code{expr} attributes to drop. The default is to drop all source-reference information.} \item{force}{If \code{\link[base:logical]{TRUE}}, existing cached results are ignored.} } \value{ Returns the value of the evaluated \code{expr} \code{\link[base]{expression}}, if any. } \examples{ for (kk in 1:5) { cat(sprintf("Iteration #\%d:\n", kk)) res <- evalWithMemoization({ cat("Evaluating expression...") a <- 1 b <- 2 c <- 4 Sys.sleep(1) cat("done\n") b }) print(res) # Sanity checks stopifnot(a == 1 && b == 2 && c == 4) # Clean up rm(a, b, c) } # for (kk ...) ## OUTPUTS: ## Iteration #1: ## Evaluating expression...done ## [1] 2 ## Iteration #2: ## [1] 2 ## Iteration #3: ## [1] 2 ## Iteration #4: ## [1] 2 ## Iteration #5: ## [1] 2 ############################################################ # WARNING ############################################################ # If the expression being evaluated depends on # "input" objects, then these must be be specified # explicitly as "key" objects. for (ii in 1:2) { for (kk in 1:3) { cat(sprintf("Iteration #\%d:\n", kk)) res <- evalWithMemoization({ cat("Evaluating expression...") a <- kk Sys.sleep(1) cat("done\n") a }, key=list(kk=kk)) print(res) # Sanity checks stopifnot(a == kk) # Clean up rm(a) } # for (kk ...) } # for (ii ...) ## OUTPUTS: ## Iteration #1: ## Evaluating expression...done ## [1] 1 ## Iteration #2: ## Evaluating expression...done ## [1] 2 ## Iteration #3: ## Evaluating expression...done ## [1] 3 ## Iteration #1: ## [1] 1 ## Iteration #2: ## [1] 2 ## Iteration #3: ## [1] 3 } \author{Henrik Bengtsson} \seealso{ Internally, \code{\link[base]{eval}}() is used to evaluate the expression. } \keyword{programming} \keyword{IO} R.cache/man/addMemoization.Rd0000644000176200001440000000275614266251111015534 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % addMemoization.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{addMemoization} \alias{addMemoization.default} \alias{addMemoization} \title{Creates a copy of an existing function such that its results are memoized} \description{ Creates a copy of an existing function such that its results are memoized. } \usage{ \method{addMemoization}{default}(fcn, envir=parent.frame(), ...) } \arguments{ \item{fcn}{A \code{\link[base]{function}} (or the name of a function) that should be copied and have memoization added.} \item{envir}{The \code{\link[base]{environment}} from where to look for the function.} \item{...}{Additional arguments for controlling the memoization, i.e. all arguments of \code{\link{memoizedCall}}() that are not passed to \code{\link[base]{do.call}}().} } \value{ Returns a \code{\link[base]{function}}. } \details{ The new function is setup such that the the memoized call is done in the environment of the caller (the parent frame of the function). If the \code{\link[base]{function}} returns \code{\link[base]{NULL}}, that particular function call is \emph{not} memoized. } \author{Henrik Bengtsson} \seealso{ The returned function utilized \code{\link{memoizedCall}}() internally. } \keyword{programming} \keyword{IO} R.cache/man/getChecksum.Rd0000644000176200001440000000344514266251111015026 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % getChecksum.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{getChecksum} \alias{getChecksum.default} \alias{getChecksum} \title{Generates a deterministic checksum for an R object} \description{ Generates a deterministic checksum for an R object such that (i) if the same object is used again, then the same checksum is obtained, and (ii) if another object is used, then a different checksum is obtained with extremely high probability. In other words, it is highly unlikely that two different objects have the same checksum. } \usage{ \method{getChecksum}{default}(object, ...) } \arguments{ \item{object}{The object for which a checksum should be calculated.} \item{...}{Additional arguments passed to \code{\link[digest]{digest}}.} } \value{ Returns checksum represented as a \code{\link[base]{character}} string. } \details{ Because \code{getChecksum()} is a generic function, it is possible to provide custom methods for specific classes of objects. This means that, if a certain class specifies fields that carry auxiliary data, then these can be excluded from the checksum calculation. For instance, assume that all objects of class 'TimestampedObject' contain timestamps specifying when each object was created. Then a custom \code{getChecksum()} method for this class can first drop the timestamp and then call the default \code{getChecksum()} function. } \author{Henrik Bengtsson} \seealso{ Internally, the \code{\link[digest]{digest}} method is used to calculate the checksum. } \keyword{programming} \keyword{IO} \keyword{internal} R.cache/man/setupCacheRootPath.Rd0000644000176200001440000000270114266251111016323 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % setupCacheRootPath.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{setupCacheRootPath} \alias{setupCacheRootPath.default} \alias{setupCacheRootPath} \title{Interactively offers the user to set up the default root path} \description{ Interactively offers the user to set up the default root path. } \usage{ \method{setupCacheRootPath}{default}(defaultPath=NULL, ...) } \arguments{ \item{defaultPath}{Default root path to set.} \item{...}{Not used.} } \value{ Returns (invisibly) the root path, or \code{\link[base]{NULL}} if running a non-interactive session. } \details{ If the cache root path is already set, it is used and nothing is done. If the "default" root path (\code{defaultPath}) exists, it is used, otherwise, if running interactively, the user is asked to approve the usage (and creation) of the default root path. In all other cases, the cache root path is set to a session-specific temporary directory. } \author{Henrik Bengtsson} \seealso{ Internally, \code{\link{setCacheRootPath}}() is used to set the cache root path. The \code{\link[base]{interactive}}() function is used to test whether \R is running interactively or not. } \keyword{programming} \keyword{IO} \keyword{internal} R.cache/man/R.cache-package.Rd0000644000176200001440000000567414266251111015426 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % 999.package.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{R.cache-package} \alias{R.cache-package} \alias{R.cache} \docType{package} \title{Package R.cache} \description{ Memoization can be used to speed up repetitive and computational expensive function calls. The first time a function that implements memoization is called the results are stored in a cache memory. The next time the function is called with the same set of parameters, the results are momentarily retrieved from the cache avoiding repeating the calculations. With this package, any R object can be cached in a key-value storage where the key can be an arbitrary set of R objects. The cache memory is persistent (on the file system). } \section{Installation and updates}{ To install this package and all of its dependent packages, do: \code{install.packages("R.cache")} } \section{To get started}{ \itemize{ \item{\link{loadCache}, \link{saveCache}}{ Methods for loading and saving objects from and to the cache. } \item{\link{getCacheRootPath}, \link{setCacheRootPath}}{ Methods for getting and setting the directory where cache files are stored. } } } \section{How to cite this package}{ Whenever using this package, please cite [1] as \preformatted{ Bengtsson, H. The R.oo package - Object-Oriented Programming with References Using Standard R Code, Proceedings of the 3rd International Workshop on Distributed Statistical Computing (DSC 2003), ISSN 1609-395X, Hornik, K.; Leisch, F. & Zeileis, A. (ed.), 2003 } } \section{Wishlist}{ Here is a list of features that would be useful, but which I have too little time to add myself. Contributions are appreciated. \itemize{ \item Add a functionality to identify cache files that are no longer of use. For now, there is an extra header field for arbitrary comments which can be used, but maybe more formal fields are useful, e.g. keywords, user, etc? } If you consider implement some of the above, make sure it is not already implemented by downloading the latest "devel" version! } \section{Related work}{ See also the \pkg{filehash} package, and the \code{cache()} function in the \pkg{Biobase} package of Bioconductor. } \author{Henrik Bengtsson} \section{License}{ The releases of this package is licensed under LGPL version 2.1 or newer. } \section{References}{ [1] H. Bengtsson, \emph{The R.oo package - Object-Oriented Programming with References Using Standard R Code}, In Kurt Hornik, Friedrich Leisch and Achim Zeileis, editors, Proceedings of the 3rd International Workshop on Distributed Statistical Computing (DSC 2003), March 20-22, Vienna, Austria. \url{https://www.r-project.org/conferences/DSC-2003/Proceedings/} \cr } \keyword{package} R.cache/man/clearCache.Rd0000644000176200001440000000311214266251111014565 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % clearCache.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{clearCache} \alias{clearCache.default} \alias{clearCache} \title{Removes all files in a cache file directory} \description{ Removes all files in a cache file directory. } \usage{ \method{clearCache}{default}(path=getCachePath(...), ..., recursive=FALSE, prompt=TRUE && interactive()) } \arguments{ \item{path}{A \code{\link[base]{character}} string specifying the directory to be cleared. By default, the path is what is returned by \code{\link{getCachePath}}() which arguments \code{...} are also passed.} \item{...}{Arguments passed to \code{\link{getCachePath}}(), especially argument \code{dirs} to specify subdirectories.} \item{recursive}{If \code{\link[base:logical]{TRUE}}, subdirectories are also removed, otherwise just the files in the specified directory.} \item{prompt}{If \code{\link[base:logical]{TRUE}}, the user will be prompted to confirm that the directory will cleared before files are removed.} } \value{ Returns (invisibly) a \code{\link[base]{character}} \code{\link[base]{vector}} of pathnames of the files removed. If no files were removed, \code{\link[base]{NULL}} is returned. } \author{Henrik Bengtsson} \details{ If the specified directory does not exists, an exception is thrown. } \keyword{programming} \keyword{IO} \keyword{internal} R.cache/man/setCacheRootPath.Rd0000644000176200001440000000143014266251111015754 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % setCacheRootPath.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{setCacheRootPath} \alias{setCacheRootPath.default} \alias{setCacheRootPath} \title{Sets the root path to the file cache directory} \description{ Sets the root path to the file cache directory. } \usage{ \method{setCacheRootPath}{default}(path=NULL, ...) } \arguments{ \item{path}{The path.} \item{...}{Not used.} } \value{ Returns (invisibly) the old root path. } \author{Henrik Bengtsson} \seealso{ \code{\link{getCacheRootPath}}(). } \keyword{programming} \keyword{IO} R.cache/man/Non-documented_objects.Rd0000644000176200001440000000176014266251111017152 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % 999.NonDocumentedObjects.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{Non-documented objects} \alias{Non-documented objects} \title{Non-documented objects} % File cache % Class Object \alias{getChecksum.Object} % Misc. \alias{.textPrompt} \description{ This page contains aliases for all "non-documented" objects that \code{R CMD check} detects in this package. Almost all of them are \emph{generic} functions that have specific document for the corresponding method coupled to a specific class. Other functions are re-defined by \code{setMethodS3()} to \emph{default} methods. Neither of these two classes are non-documented in reality. The rest are deprecated methods. } \author{Henrik Bengtsson} \keyword{documentation} \keyword{internal} R.cache/man/generateCache.Rd0000644000176200001440000000241414266251111015275 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % generateCache.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{generateCache} \alias{generateCache.default} \alias{generateCache} \title{Generates a cache pathname from a key object} \description{ Generates a cache pathname from a key object. } \usage{ \method{generateCache}{default}(key, suffix=".Rcache", ...) } \arguments{ \item{key}{A \code{\link[base]{list}} or an \code{\link[base]{environment}} from which a \code{\link[base]{character}} string checksum will be calculated and that will constitute the name part of the cache filename.} \item{suffix}{A \code{\link[base]{character}} string to be appended to the end of the filename.} \item{...}{Arguments passed to \code{\link{getCachePath}}().} } \value{ Returns the pathname as a \code{\link[base]{character}} string. } \author{Henrik Bengtsson} \seealso{ \code{\link{findCache}}(). Internally, the generic function \code{\link{getChecksum}}() is used to calculate the checksum of argument \code{key}. } \keyword{programming} \keyword{IO} \keyword{internal} R.cache/man/000.baseLoad.Rd0000644000176200001440000000345714266251111014577 0ustar liggesusers%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not modify this file since it was automatically generated from: % % private.baseLoad.R % % by the Rdoc compiler part of the R.oo package. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \name{.baseLoad} \alias{.baseLoad} \title{Loads an object from a file connection} \description{ Loads an object from a file connection similar to \code{\link[base]{load}}(), but without resetting file connections (to position zero). \emph{WARNING: This is an internal function that should not be called by anything but the internal code of the \pkg{R.cache} package.} } \usage{ .baseLoad(con, envir=parent.frame()) } \arguments{ \item{con}{A \code{\link[base:connections]{connection}}.} \item{envir}{An \code{\link[base]{environment}} where the loaded object will be stored.} } \value{ Returns (invisible) a \code{\link[base]{character}} \code{\link[base]{vector}} of the names of objects loaded. } \details{ The reason why it is not possible to use \code{\link[base]{load}}() is that that resets the file position of the connection before trying to load the object. The reason why that happens is because when you pass a regular file connection to \code{\link[base]{load}}() it gets coerced via \code{\link[base]{gzcon}}(), which is the function that resets the file position. The workaround is to create a local copy of \code{base::load()} and modify it by dropping the \code{gzcon()} coercion. This is possible because this function, that is \code{.baseLoad()}, is always called with a \code{gzfile()} \code{\link[base:connections]{connection}}. } \seealso{ This function is used by \code{\link{loadCache}}() and \code{\link{readCacheHeader}}(). } \keyword{internal} R.cache/DESCRIPTION0000755000176200001440000000247014266276262013246 0ustar liggesusersPackage: R.cache Version: 0.16.0 Depends: R (>= 2.14.0) Imports: utils, R.methodsS3 (>= 1.8.1), R.oo (>= 1.24.0), R.utils (>= 2.10.1), digest (>= 0.6.13) Title: Fast and Light-Weight Caching (Memoization) of Objects and Results to Speed Up Computations Authors@R: c(person("Henrik", "Bengtsson", role=c("aut", "cre", "cph"), email = "henrikb@braju.com")) Author: Henrik Bengtsson [aut, cre, cph] Maintainer: Henrik Bengtsson Description: Memoization can be used to speed up repetitive and computational expensive function calls. The first time a function that implements memoization is called the results are stored in a cache memory. The next time the function is called with the same set of parameters, the results are momentarily retrieved from the cache avoiding repeating the calculations. With this package, any R object can be cached in a key-value storage where the key can be an arbitrary set of R objects. The cache memory is persistent (on the file system). License: LGPL (>= 2.1) LazyLoad: TRUE URL: https://github.com/HenrikBengtsson/R.cache BugReports: https://github.com/HenrikBengtsson/R.cache/issues RoxygenNote: 7.2.1 NeedsCompilation: no Packaged: 2022-07-21 13:19:33 UTC; hb Repository: CRAN Date/Publication: 2022-07-21 16:20:02 UTC R.cache/tests/0000755000176200001440000000000014043103161012650 5ustar liggesusersR.cache/tests/setCachePath.R0000644000176200001440000000040513340347143015337 0ustar liggesuserslibrary("R.cache") setCachePath <- R.cache:::setCachePath ## Use an empty temporary file cache tmpdir <- tempdir() setCacheRootPath(path=tmpdir) dirs <- c("tests", "readCacheHeader") setCachePath(dirs=dirs, path=tmpdir) ## Cleanup clearCache(recursive=TRUE) R.cache/tests/clearCache.R0000644000176200001440000000070113340347143015014 0ustar liggesuserslibrary("R.cache") ## Use an empty temporary file cache setCacheRootPath(path=file.path(tempdir())) ## Try to clear it clearCache(recursive=TRUE, prompt=FALSE) clearCache(recursive=TRUE, prompt=TRUE) dirs <- c("tests", "clearCache") saveCache(1, key=list("clearCache"), dirs=dirs) clearCache(recursive=FALSE, prompt=TRUE) clearCache(recursive=TRUE, prompt=TRUE) clearCache(recursive=FALSE, prompt=FALSE) clearCache(recursive=TRUE, prompt=FALSE) R.cache/tests/textPrompt.R0000644000176200001440000000056013340347143015173 0ustar liggesuserstextPrompt <- R.cache:::.textPrompt ans <- textPrompt("Do you have a minute?") print(ans) ans <- textPrompt("Do you have a minute?", options=c("yes", "no")) print(ans) ## Output to standard error ans <- textPrompt("Do you have a minute?", type="message") print(ans) ## Output to standard output ans <- textPrompt("Do you have a minute?", type="output") print(ans) R.cache/tests/StaticMethodsAndNamespaces.R0000644000176200001440000000005013340347143020175 0ustar liggesusersR.cache::clearCache(dirs=sample(1:10)) R.cache/tests/getCacheRootPath.R0000644000176200001440000000105613572460205016174 0ustar liggesuserslibrary("R.cache") setupCacheRootPath <- R.cache:::setupCacheRootPath oopts <- options() tmpdir <- tempdir() setCacheRootPath(path=tmpdir) print(getCacheRootPath()) setupCacheRootPath(defaultPath=tmpdir) path <- getCacheRootPath(NULL) print(path) stopifnot(identical(path, tmpdir)) options("R.cache.rootPath"=NULL) print(getCacheRootPath()) path <- getCacheRootPath(NULL) print(path) stopifnot(is.null(path)) setupCacheRootPath(defaultPath=tmpdir) path <- getCacheRootPath(NULL) print(path) stopifnot(identical(path, tmpdir)) ## Reset options(oopts) R.cache/tests/addMemoization.R0000644000176200001440000000314313340347143015751 0ustar liggesuserslibrary("R.cache") # Use an empty temporary file cache setCacheRootPath(path=file.path(tempdir())) clearCache(recursive=TRUE, prompt=FALSE) dirs <- c("tests", "addMemoization") # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Define function to be memoized # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sleep <- function(time) { cat(sprintf("Sleeping for %g seconds...\n", time)) Sys.sleep(time) cat(sprintf("Sleeping for %g seconds...done\n", time)) time } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Test memoization # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sleep <- addMemoization(sleep) # There will be no cache hit for the first call t0 <- system.time({ res0 <- sleep(1.5) })[3] print(t0) # The second will have a cache hit and therefore # return the memoized results momentarily. t1 <- system.time({ res1 <- sleep(1.5) })[3] print(t1) print(t1/t0) # Sanity check stopifnot(identical(res1, res0)) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Don't memoize already memoized functions # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sleep2 <- addMemoization(sleep) stopifnot(identical(sleep2, sleep)) sleep3 <- addMemoization("sleep") stopifnot(identical(sleep3, sleep)) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Exception handling # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - res <- try(addMemoization("non-existing-function"), silent=TRUE) stopifnot(inherits(res, "try-error")) res <- try(addMemoization(NULL), silent=TRUE) stopifnot(inherits(res, "try-error")) R.cache/tests/DEPRECATED.R0000644000176200001440000000076513572460205014416 0ustar liggesuserslibrary("R.cache") options(R.cache.rootPath = NULL) ## ----------------------------------------------- ## DEPRECATED & DEFUNCT ## ----------------------------------------------- options("R.cache.path"="foo") res <- tryCatch(getCacheRootPath(), error = identity) print(res) stopifnot(inherits(res, "error")) options("R.cache.path"=NULL) Sys.setenv("R_CACHE_PATH"="foo") res <- tryCatch(getCacheRootPath(), error = identity) print(res) stopifnot(inherits(res, "error")) Sys.setenv("R_CACHE_PATH"="") R.cache/tests/setCacheRootPath.R0000644000176200001440000000027613340347143016211 0ustar liggesuserslibrary("R.cache") tmpdir <- tempdir() setCacheRootPath(path=tmpdir) setCacheRootPath(path=file.path(tmpdir, "subdir")) setCacheRootPath(path=tmpdir) ## Cleanup clearCache(recursive=TRUE) R.cache/tests/assertDigest.R0000644000176200001440000000011413340347143015441 0ustar liggesusersR.cache:::.assertDigest() library("R.cache") R.cache:::.assertDigest() R.cache/tests/readCacheHeader.R0000644000176200001440000000105113340347143015751 0ustar liggesuserslibrary("R.cache") ## Use an empty temporary file cache setCacheRootPath(path=file.path(tempdir())) dirs <- c("tests", "readCacheHeader") for (compress in c(FALSE, TRUE)) { pathname <- saveCache(1, key=list("readCacheHeader"), dirs=dirs, compress=compress) for (byName in c(FALSE, TRUE)) { if (byName) { hdr <- readCacheHeader(pathname) } else { con <- gzfile(pathname, open="rb") hdr <- readCacheHeader(con) close(con) } str(list(pathname=pathname, hdr=hdr)) } } ## Cleanup clearCache(recursive=TRUE) R.cache/tests/loadCache.R0000644000176200001440000000163113340347143014650 0ustar liggesuserslibrary("R.cache") oopts <- options("R.cache.compress") simulate <- function(mean, sd) { # 1. Try to load cached data, if already generated key <- list(mean, sd) data <- loadCache(key) if (!is.null(data)) { cat("Loaded cached data\n") return(data) } # 2. If not available, generate it. cat("Generating data from scratch...") data <- rnorm(1000, mean=mean, sd=sd) Sys.sleep(1) # Emulate slow algorithm cat("ok\n") saveCache(data, key=key, comment="simulate()") data } for (compress in c(FALSE, TRUE)) { options("R.cache.compress"=compress) data <- simulate(2.3, 3.0) data <- simulate(2.3, 3.5) data <- simulate(2.3, 3.0) # Will load cached data # Clean up file.remove(findCache(key=list(2.3,3.0))) file.remove(findCache(key=list(2.3,3.5))) } ## Exceptions res <- try(findCache(key = NULL)) stopifnot(inherits(res, "try-error")) ## Cleanup options(oopts) R.cache/tests/memoizedCall.R0000644000176200001440000000217413340347143015415 0ustar liggesuserslibrary("R.cache") # Use an empty temporary file cache setCacheRootPath(path=file.path(tempdir())) clearCache(recursive=TRUE, prompt=FALSE) dirs <- c("tests", "memoizedCall") # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Define function to be memoized # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sleep <- function(time) { cat(sprintf("Sleeping for %g seconds...\n", time)) Sys.sleep(time) cat(sprintf("Sleeping for %g seconds...done\n", time)) time } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Test memoization # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # There will be no cache hit for the first call t0 <- system.time({ res0 <- memoizedCall(sleep, time=1.5, dirs=dirs) })[3] print(t0) # The second will have a cache hit and therefore # return the memoized results momentarily. t1 <- system.time({ res1 <- memoizedCall(sleep, time=1.5, dirs=dirs) })[3] print(t1) if (t1 >= t0) { warning("Second call to memoizedCall() took longer than the first: ", t1, " >= ", t0) } # Sanity check stopifnot(identical(res1, res0)) clearCache(recursive=TRUE) R.cache/tests/getCachePath.R0000644000176200001440000000027213340347143015325 0ustar liggesuserslibrary("R.cache") root <- getCacheRootPath() print(root) path <- getCachePath(dirs=c("abc", "def")) print(path) path <- getCachePath(dirs=c("abc", "def"), path="subdir") print(path) R.cache/tests/findOSCachePath.R0000644000176200001440000000300214043103161015711 0ustar liggesuserslibrary(R.cache) findOSCachePath <- R.cache:::findOSCachePath getOS <- R.cache:::getOS message("findOSCachePath() ...") oses <- getOS() if (isTRUE(as.logical(Sys.getenv("R_CHECK_FULL", "FALSE")))) { oses <- c("unix", "windows", "macos") } for (os in oses) { message("Operating system: ", sQuote(os)) message("- getOS(): ", sQuote(getOS())) ## Fake the OS? fake_os <- (os != getOS()) if (fake_os) { if (os == "windows") { Sys.setenv(LOCALAPPDATA = normalizePath("~/AppData/Local", mustWork = FALSE)) } } path <- findOSCachePath(os) message("- findOSCachePath(): ", sQuote(path)) if (getRversion() >= "4.0.0") { R_user_dir <- tools::R_user_dir path_R <- local({ if (fake_os) { if (os == "macos") { tracer <- quote(Sys.info <- function() c(sysname = "Darwin")) } else { tracer <- quote(.Platform <- list(OS.type = os)) } trace(R_user_dir, tracer = tracer) on.exit(untrace(R_user_dir)) } R_user_dir("R.cache", which = "cache") }) message("- R_user_dir('R.cache', which = 'cache'): ", sQuote(path_R)) path_R <- normalizePath(path_R, mustWork = FALSE) message("- Normalized version: ", sQuote(path_R)) res <- identical(path, path_R) message("- Identical to findOSCachePath(): ", res) if (!res) { message("- findOSCachePath() differ from R_user_dir(): ", sQuote(path), " != ", sQuote(path_R)) } } } ## for (os ...) message("findOSCachePath() ... done") R.cache/tests/evalWithMemoization.R0000644000176200001440000000166313340347143017011 0ustar liggesuserslibrary("R.cache") for (kk in 1:5) { cat(sprintf("Iteration #%d:\n", kk)) res <- evalWithMemoization({ cat("Evaluating expression...") a <- 1 b <- 2 c <- 4 cat("done\n") b }) print(res) # Sanity checks stopifnot(a == 1 && b == 2 && c == 4) # Clean up rm(list=c("a", "b", "c")) } # for (kk ...) ############################################################ # WARNING ############################################################ # If the expression being evaluated depends on # "input" objects, then these must be be specified # explicitly as "key" objects. for (ii in 1:2) { for (kk in 1:3) { cat(sprintf("Iteration #%d:\n", kk)) res <- evalWithMemoization({ cat("Evaluating expression...") a <- kk cat("done\n") a }, key=list(kk=kk)) print(res) # Sanity checks stopifnot(a == kk) # Clean up rm(list=c("a")) } # for (kk ...) } # for (ii ...) R.cache/tests/Object.getChecksum.R0000644000176200001440000000012313340347143016447 0ustar liggesuserslibrary("R.cache") obj <- R.oo::Object() obj$value <- 42L print(getChecksum(obj)) R.cache/R/0000755000176200001440000000000014266246363011732 5ustar liggesusersR.cache/R/setCachePath.R0000644000176200001440000000171313572460205014403 0ustar liggesusers#########################################################################/** # @RdocDefault setCachePath # # @title "Sets the path to the file cache directory" # # \description{ # @get "title". # } # # @synopsis # # \arguments{ # \item{dirs}{A @character @vector constituting the path to the # cache subdirectory of interest.} # \item{path}{The path to override the path according to the # \code{dirs} argument.} # \item{...}{Not used.} # } # # \value{ # Returns nothing. # } # # @author # # \seealso{ # @see "getCachePath". # } # # @keyword "programming" # @keyword "IO" # @keyword "internal" #*/######################################################################### setMethodS3("setCachePath", "default", function(dirs=NULL, path=NULL, ...) { subname <- paste(dirs, collapse="/") name <- paste("R.cache:cachePath", subname, sep=":") opts <- list(path) names(opts) <- name ovalue <- options(opts) invisible(ovalue) }, export=FALSE) R.cache/R/999.package.R0000644000176200001440000000335013572460205013772 0ustar liggesusers#########################################################################/** # @RdocPackage R.cache # # \description{ # @eval "getDescription(R.cache)" # } # # \section{Installation and updates}{ # To install this package and all of its dependent packages, do: # \code{install.packages("R.cache")} # } # # \section{To get started}{ # \itemize{ # \item{\link{loadCache}, \link{saveCache}}{ # Methods for loading and saving objects from and to the cache. # } # \item{\link{getCacheRootPath}, \link{setCacheRootPath}}{ # Methods for getting and setting the directory where cache # files are stored. # } # } # } # # \section{How to cite this package}{ # Whenever using this package, please cite [1] as # # @howtocite "R.oo" # } # # \section{Wishlist}{ # Here is a list of features that would be useful, but which I have # too little time to add myself. Contributions are appreciated. # \itemize{ # \item Add a functionality to identify cache files that are # no longer of use. For now, there is an extra header field # for arbitrary comments which can be used, but maybe more # formal fields are useful, e.g. keywords, user, etc? # } # # If you consider implement some of the above, make sure it is not # already implemented by downloading the latest "devel" version! # } # # \section{Related work}{ # See also the \pkg{filehash} package, and the \code{cache()} function # in the \pkg{Biobase} package of Bioconductor. # } # # @author # # \section{License}{ # The releases of this package is licensed under LGPL version 2.1 or newer. # } # # \section{References}{ # [1] @include "../incl/BengtssonH_2003.bib.Rdoc" \cr # } #*/######################################################################### R.cache/R/clearCache.R0000644000176200001440000001131413572460205014057 0ustar liggesusers#########################################################################/** # @RdocDefault clearCache # # @title "Removes all files in a cache file directory" # # \description{ # @get "title". # } # # @synopsis # # \arguments{ # \item{path}{A @character string specifying the directory to be cleared. # By default, the path is what is returned by @see "getCachePath" # which arguments \code{...} are also passed.} # \item{...}{Arguments passed to @see "getCachePath", especially # argument \code{dirs} to specify subdirectories.} # \item{recursive}{If @TRUE, subdirectories are also removed, otherwise # just the files in the specified directory.} # \item{prompt}{If @TRUE, the user will be prompted to confirm that # the directory will cleared before files are removed.} # } # # \value{ # Returns (invisibly) a @character @vector of pathnames of the # files removed. If no files were removed, @NULL is returned. # } # # @author # # \details{ # If the specified directory does not exists, an exception is thrown. # } # # @keyword "programming" # @keyword "IO" # @keyword "internal" #*/######################################################################### setMethodS3("clearCache", "default", function(path=getCachePath(...), ..., recursive=FALSE, prompt=TRUE && interactive()) { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Validate arguments # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Argument 'recursive': recursive <- Arguments$getLogical(recursive) # Argument 'path': path <- Arguments$getReadablePath(path, mustExist=TRUE) # Argument 'prompt': prompt <- Arguments$getLogical(prompt) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Find files to be removed # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - allFiles <- listDirectory(path, allNames=TRUE, fullNames=TRUE, recursive=recursive) # Exclude '.' and '..' (just in case; listDirectory() shouldn't return them) excl <- grep("[.][.]*$", allFiles) if (length(excl) > 0L) allFiles <- allFiles[-excl] # Exclude 'README.txt' excl <- grep("README.txt$", allFiles) if (length(excl) > 0L) allFiles <- allFiles[-excl] nbrOfFiles <- length(allFiles) if (nbrOfFiles == 0L) { if (prompt) { message("Nothing to clear. Cache directory is empty: ", path, "\n", sep="") } return(invisible(NULL)) } # Identify files and directories isdir <- file.info(allFiles)$isdir dirs <- allFiles[isdir] files <- allFiles[!isdir] # Remove subdirectories before parent ones. o <- order(nchar(dirs), decreasing=TRUE) dirs <- dirs[o] # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Prompt user? # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (prompt) { answer <- "." while (!(answer %in% c("y", "n", ""))) { msg <- sprintf("Are you sure you want to delete the %d files and %d directories in '%s'? [y/N]: ", length(files), length(dirs), path) answer <- tolower(readline(msg)) } if (answer != "y") { return(invisible(NULL)) } } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Remove files and directories # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # (a) Remove files removed <- file.remove(files) filesR <- files[!removed] # (b) Remove subdirectories # Here we could use unlink(..., recursive=TRUE), but it is # SUPER-DUPER DANGEROUS to do that, because it may spawn off a # recursive deletion in a different place (in case there is a # bug or an inconsistency in list.files() etc), but also if we # forget to drop '.' and '..' from list.files(). /HB 2012-11-28 removed <- sapply(dirs, FUN=function(dir) { filesT <- list.files(path=dir, all.files=TRUE) filesT <- setdiff(filesT, c(".", "..")) # Remove only empty directories if (length(filesT) > 0L) return(FALSE) removeDirectory(dir) }) dirsR <- dirs[!removed] # Files and directories removed files <- sort(setdiff(files, filesR)) dirs <- sort(setdiff(dirs, dirsR)) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Report results? # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (prompt) { msg <- sprintf("Cache cleared. Removed %d files and %d directories", length(files), length(dirs)) if (length(filesR) + length(dirsR) > 0L) { msg <- sprintf("%s, but failed to remove another %d files and another %d directories", msg, length(filesR), length(dirsR)) } message(sprintf("%s.\n", msg)) } # Add a README.txt file, if missing. .addREADME() invisible(c(dirs, files)) }) R.cache/R/textPrompt.R0000644000176200001440000000306313572460205014235 0ustar liggesusers.textPrompt <- function(prompt, options=c("Y"="yes", "n"="no"), caseSensitive=FALSE, maxTries=Inf, type=c("message", "output"), onSink=c("error", "ignore"), ...) { # Argument 'maxTries': maxTries <- Arguments$getNumeric(maxTries, range=c(1,Inf)) # Argument 'onSink': onSink <- match.arg(onSink) # Argument 'type': type <- match.arg(type) # Check if standard output is redirected. # NOTE: There always *2* sinks for type="message", cf. help("sink"). minSink <- switch(type, message=2L, 0L) hasSink <- (sink.number(type=type) > minSink) if (hasSink) { if (onSink == "error") { throw("Cannot prompt user via the standard ", type, ", because it is currently redirected and (most likely) not visible to the user.") } } # How to present the options to the user keys <- names(options) if (is.null(keys)) { keys <- options } promptF <- sprintf("%s [%s]: ", prompt, paste(keys, collapse="/")) promptR <- gettext("Unknown reply.\n") # Where to prompt if (type == "output") { con <- stdout() } else { con <- stderr() } count <- 0L while (count < maxTries) { cat(file=con, promptF) ans <- readline() count <- count + 1L ans <- trim(ans) if (ans == "") { idx <- 1L } else { if (caseSensitive) { idx <- pmatch(ans, options) } else { idx <- pmatch(tolower(ans), tolower(options)) } } if (is.finite(idx)) { ans <- options[idx] break } cat(file=con, promptR) } # while(...) attributes(ans) <- NULL ans } # .textPrompt() R.cache/R/private.baseLoad.R0000644000176200001440000000453113572460205015233 0ustar liggesusers###########################################################################/** # @eval "{.baseLoad <<- R.cache:::.baseLoad; ''}" # @RdocFunction ".baseLoad" # # @title "Loads an object from a file connection" # # \description{ # @get "title" similar to @see "base::load", but without resetting # file connections (to position zero). # # \emph{WARNING: This is an internal function that should not be # called by anything but the internal code of the \pkg{R.cache} package.} # } # # @synopsis # # \arguments{ # \item{con}{A @connection.} # \item{envir}{An @environment where the loaded object will be stored.} # } # # \value{ # Returns (invisible) a @character @vector of the names of objects # loaded. # } # # \details{ # The reason why it is not possible to use @see "base::load" is that # that resets the file position of the connection before trying to # load the object. # The reason why that happens is because when you pass a regular file # connection to @see "base::load" it gets coerced via @see "base::gzcon", # which is the function that resets the file position. # # The workaround is to create a local copy of \code{base::load()} and # modify it by dropping the \code{gzcon()} coercion. This is possible # because this function, that is \code{.baseLoad()}, is always called # with a \code{gzfile()} @connection. # } # # \seealso{ # This function is used by @see "loadCache" and @see "readCacheHeader". # } # # @keyword internal #*/########################################################################### .baseLoad <- function(con, envir=parent.frame()) { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Assert correctness of connection # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - magic <- readChar(con, nchars=5, useBytes=TRUE) if (regexpr("RD[AX][2-9]\n", magic) == -1L) { if (regexpr("RD[ABX][1-9]\r", magic) == 1L) { stop("input has been corrupted, with LF replaced by CR") } else { stop(gettextf("file '%s' has magic number '%s'\n Use of save versions prior to 2 is deprecated", summary(file)$description, gsub("[\n\r]*", "", magic))) } } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Load object from connection # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - res <- readRDS(con) } # .baseLoad() R.cache/R/zzz.R0000644000176200001440000000122714040060737012701 0ustar liggesusers## covr: skip=all .onLoad <- function(libname, pkgname) { ns <- getNamespace(pkgname) pkg <- Package(pkgname) assign(pkgname, pkg, envir=ns) ## Use a temporary root path for 'R CMD check', unless explicitly set if (inRCmdCheck()) { path <- getOption("R.cache.rootPath", Sys.getenv("R_CACHE_ROOTPATH")) if (nchar(path) == 0L) { path <- file.path(tempdir(), ".cache", "R", "R.cache") options(R.cache.rootPath = path) } } # Setup the cache root path, possibly by prompting the user. setupCacheRootPath() } .onAttach <- function(libname, pkgname) { pkg <- get(pkgname, envir=getNamespace(pkgname)) startupMessage(pkg) } R.cache/R/queryRCmdCheck.R0000644000176200001440000000415514043103161014710 0ustar liggesusersqueryRCmdCheck <- function(...) { evidences <- list() # Memoization evidences[["R_CMD_CHECK"]] <- isTRUE(as.logical(Sys.getenv("R_CMD_CHECK"))) # Command line arguments args <- commandArgs() evidences[["vanilla"]] <- is.element("--vanilla", args) # Check the working directory; any components containing .Rcheck/tests evidences[["pwd"]] <- FALSE path <- getwd() last_path <- "" while (path != last_path) { last_path <- path if (basename(path) == "tests") { if (grepl(".+[.]Rcheck$", dirname(path))) { evidences[["pwd"]] <- TRUE break } } path <- dirname(path) } # Is 'R CMD check' checking examples? evidences[["examples"]] <- is.element("CheckExEnv", search()) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Conclusions # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (evidences$R_CMD_CHECK) { res <- "R_CMD_CHECK" } else if (!evidences[["vanilla"]]) { res <- "notRunning" } else if (evidences[["examples"]]) { res <- "checkingExamples" } else if (evidences[["pwd"]]) { res <- "checkingTests" } else { res <- "notRunning" } # Make it stick if (res != "notRunning") { Sys.setenv(R_CMD_CHECK = "true") } attr(res, "evidences") <- evidences if (isTRUE(as.logical(Sys.getenv("R_R_CACHE_DEBUG")))) { file <- file.path("~", ".cache", "R", sprintf("R.cache-%d.log", Sys.getpid())) dir.create(dirname(file), recursive = TRUE, showWarnings = FALSE) cat(sprintf("Call: %s\n", paste(commandArgs(), collapse = " ")), file = file, append = TRUE) cat(sprintf("PID: %s\n", Sys.getpid()), file = file, append = TRUE) cat(sprintf("pwd: %s\n", getwd()), file = file, append = TRUE) cat(sprintf("search(): %s\n", paste(sQuote(search()), collapse = ", ")), file = file, append = TRUE) cat(sprintf("R_CMD_CHECK: %s\n", sQuote(Sys.getenv("R_CMD_CHECK", NA_character_))), file = file, append = TRUE) cat(sprintf("queryRCmdCheck(): %s\n", sQuote(res)), file = file, append = TRUE) } res } inRCmdCheck <- function() (queryRCmdCheck() != "notRunning") R.cache/R/getOSCacheRootPath.R0000644000176200001440000001337314043103161015467 0ustar liggesusersgetOS <- function() { if (.Platform[["OS.type"]] == "windows") return("windows") if (Sys.info()["sysname"] == "Darwin") return("macos") if (.Platform[["OS.type"]] == "unix") return("unix") NA_character_ } ## REFERENCES: ## [1] https://docs.microsoft.com/en-us/windows/deployment/usmt/usmt-recognized-environment-variables getWindowsLocalAppData <- function() { ## Env var 'LOCALAPPDATA' should be defined on Windows Vista and later path <- Sys.getenv("LOCALAPPDATA", NA_character_) if (!is.na(path)) return(path) ## We might end up here because we're on Windows XP or for other reasons root <- Sys.getenv("USERPROFILE", NA_character_) if (is.na(root)) return(NA_character_) ## Should not happen ## Is there an 'AppData/Local' folder? path <- file.path(root, "AppData" , "Local") if (!is.na(path)) return(path) ## Is there an 'Local Settings/Application Data' folder? (Windows XP) path <- file.path(root, "Local Settings", "Application Data") if (!is.na(path)) return(path) ## We shouldn't really end up here, but who knows ... NA_character_ } findOSCachePath_0.14.0 <- function(os = getOS()) { root <- switch(os, windows = getWindowsLocalAppData(), macos = file.path("~", "Library", "Caches"), unix = Sys.getenv("XDG_CACHE_HOME", file.path("~", ".cache")), NA_character_ ) ## Did we find a OS-specific cache folder? if (!is.na(root)) { path <- c(root, "R", "R.cache") } else { ## If not, the fall back to "~/.Rcache", which by the way was the ## default in R.cache (<= 0.13.0) path <- c("~", ".Rcache") } do.call(file.path, args = as.list(path)) } findOSCachePath_0.15.0 <- if (getRversion() >= "4.0.0") { function(os = getOS()) { # message("findOSCachePath_0.15.0() ...") # on.exit(message("findOSCachePath_0.15.0() ... done")) # message("os=", os) # message("getOS()=", getOS()) if (os != getOS()) { if (os == "macos") { tracer <- quote(Sys.info <- function() c(sysname = "Darwin")) } else { tracer <- quote(.Platform <- list(OS.type = os)) } message("- trace(tools::R_user_dir, tracer = tracer) ...") trace(tools::R_user_dir, tracer = tracer) message("- trace(tools::R_user_dir, tracer = tracer) ... done") on.exit(untrace(tools::R_user_dir)) } tools::R_user_dir(.packageName, which = "cache") } } else function(os = getOS()) { path <- Sys.getenv("R_USER_CACHE_DIR", NA_character_) if (is.na(path)) path <- Sys.getenv("XDG_CACHE_HOME", NA_character_) if (is.na(path)) { path <- switch(os, windows = file.path(Sys.getenv("LOCALAPPDATA"), "R", "cache"), macos = file.path("~", "Library", "Caches", "org.R-project.R"), unix = file.path("~", ".cache") ) } file.path(path, "R", .packageName) } #' @importFrom utils file_test menu findOSCachePath <- function(os = getOS(), action = c("query", "error", "warn", "remove", "move", "ignore")) { rm_folder_if_empty <- function(path) { if (!file_test("-d", path)) return(FALSE) content <- dir(path = path, all.files = TRUE) content <- setdiff(content, c(".", "..")) has_README <- ("README.md" %in% content) if (has_README) content <- setdiff(content, "README.md") if (length(content) > 0) return(TRUE) unlink(path, recursive = has_README) file_test("-d", path) } # message("findOSCachePath() ...") # on.exit(message("findOSCachePath() ... done")) action <- match.arg(action) if (action == "query") { ## Cannot query user? if (!interactive() || isTRUE(getOption("R.cache.onLoad", FALSE))) { action <- "ignore" } } path <- findOSCachePath_0.15.0(os = os) path <- normalizePath(path, mustWork = FALSE) ## Is there another, old cache folder? Can we migrate it? if (action != "ignore") { path_old <- findOSCachePath_0.14.0(os = os) path_old <- normalizePath(path_old, mustWork = FALSE) exists_old <- rm_folder_if_empty(path_old) exists <- rm_folder_if_empty(path) if (path != path_old && exists_old) { if (action == "query") { choices <- c( "Abort", "Ignore old R.cache folder", "Remove old R.cache folder", if (!exists) "Try to move it to the new location" ) repeat { ans <- menu(choices, title = "What to do with old non-empty R.cache folder?") if (ans != 0L) break } action <- c("error", "warn", "remove", "move")[ans] } if (action == "remove") { if (exists_old) { unlink(path_old, recursive = TRUE) exists_old <- file_test("-d", path_old) if (exists_old) { stop("Failed to remove all of folder: ", sQuote(path_old)) } } } else if (action == "move") { ## Can we move the whole folder as-is? if (!exists) { file.rename(path_old, path) exists <- file_test("-d", path) exists_old <- file_test("-d", path_old) if (!exists || exists_old) { stop(sprintf("Failed to move folder: %s (%s) -> %s (%s)", sQuote(path_old), if (exists_old) "still exists" else "gone", sQuote(path), if (exists) "exists" else "missing")) } } else { action <- "error" } } if (action %in% c("error", "warn")) { msg <- sprintf("There is an non-empty old-style R.cache folder that is no longer used. To reuse its content, move files and subfolders from %s to %s", sQuote(path_old), sQuote(path)) if (action == "error") stop(msg) warning(msg, immediate. = TRUE) } } } ## if (action != "ignore") path } getOSCacheRootPath <- local({ os_cache_path <- NULL function() { if (is.null(os_cache_path)) os_cache_path <<- findOSCachePath() os_cache_path } }) R.cache/R/saveCache.R0000644000176200001440000001070213572460205013727 0ustar liggesusers#########################################################################/** # @RdocDefault saveCache # # @title "Saves data to file cache" # # \description{ # @get "title", which is unique for an optional key object. # } # # @synopsis # # \arguments{ # \item{object}{The object to be saved to file.} # \item{key}{An optional object from which a hexadecimal hash # code will be generated and appended to the filename.} # \item{sources}{Source objects used for comparison of timestamps when # cache is loaded later.} # \item{suffix}{A @character string to be appended to the end of the # filename.} # \item{comment}{An optional @character string written in ASCII at the # beginning of the file.} # \item{pathname}{(Advanced) An optional @character string specifying # the pathname to the cache file. If not specified (default), a unique # one is automatically generated from arguments \code{key} and # \code{suffix} among other things.} # \item{dirs}{A @character @vector constituting the path to the # cache subdirectory (of the \emph{cache root directory} # as returned by @see "getCacheRootPath") to be used. # If @NULL, the path will be the cache root path.} # \item{compress}{If @TRUE, the cache file will be saved using # gzip compression, otherwise not.} # \item{...}{Additional argument passed to @see "base::save".} # } # # \value{ # Returns (invisible) the pathname of the cache file. # } # # \section{Compression}{ # The \code{saveCache()} method saves a compressed cache file # (with filename extension *.gz) if argument \code{compress} is @TRUE. # The @see "loadCache" method locates (via @see "findCache") and # loads such cache files as well. # } # # @author # # \examples{\dontrun{For an example, see ?loadCache}} # # \seealso{ # For more details on how the hash code is generated etc, @see "loadCache". # } # # @keyword "programming" # @keyword "IO" #*/######################################################################### setMethodS3("saveCache", "default", function(object, key=NULL, sources=NULL, suffix=".Rcache", comment=NULL, pathname=NULL, dirs=NULL, compress=NULL, ...) { # Look up base::save() once; '::' adds overhead base_save <- base::save # Argument 'compress': if (is.null(compress)) { compress <- getOption("R.cache.compress") if (is.null(compress)) { compress <- getOption("R.cache::compress") if (!is.null(compress)) .Defunct(msg = "R.cache option 'R.cache::compress' has been renamed to 'R.cache.compress'") } } if (!isTRUE(compress)) compress <- FALSE ## Skip cache? if (!getOption("R.cache.enabled", TRUE)) return(NULL) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Cache file # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (is.null(pathname)) { # Generate cache name from basename and hash object. pathname <- generateCache(key=key, suffix=suffix, dirs=dirs) } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Save to file connection # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (compress) { pathname <- sprintf("%s.gz", pathname) fh <- gzfile(pathname, open="wb") } else { fh <- file(pathname, open="wb") } on.exit(close(fh)) ## Prepare to save identifier <- "Rcache v0.1.7 (R package R.cache by Henrik Bengtsson)" if (nchar(identifier) > 64L) throw("Internal error. Identifier is too long: ", identifier) tail <- paste(rep(" ", times=64L-nchar(identifier)), collapse="") identifier <- paste(identifier, tail, sep="") if (is.null(comment)) comment <- "" # If 'sources' is not evaluated, it is a so called promise, which will # make all of its calling environments to be save too. dummy <- is.null(sources) timestamp <- Sys.time() tryCatch({ # Save 'identifier' writeChar(con=fh, identifier, nchars=64L) # Save 'comment' writeBin(con=fh, nchar(comment), size=4L) writeChar(comment, con=fh, nchars=nchar(comment)) # Save 'sources' base_save(file=fh, sources, compress=compress, ...) # Save 'timestamp' base_save(file=fh, timestamp, compress=compress, ...) # Save 'object' base_save(file=fh, object, compress=compress, ...) }, error = function(ex) { msg <- conditionMessage(ex) throw(sprintf("Failed to save to cache (%s). The reason was: %s", sQuote(pathname), ex)) }) invisible(pathname) }) R.cache/R/addREADME.R0000644000176200001440000000052613572460205013456 0ustar liggesusers.addREADME <- function(to=getCacheRootPath(), ...) { # Add a README.txt to cache root (expaining what the directory is) filename <- "README.txt" pathnameD <- file.path(to, filename) if (!isFile(pathnameD)) { pathnameS <- system.file("_Rcache", filename, package="R.cache") file.copy(pathnameS, pathnameD) } } # .addREADME() R.cache/R/getChecksum.R0000644000176200001440000000323013572460205014305 0ustar liggesusers#########################################################################/** # @RdocDefault getChecksum # # @title "Generates a deterministic checksum for an R object" # # \description{ # @get "title" such that (i) if the same object is used again, then # the same checksum is obtained, and (ii) if another object is used, # then a different checksum is obtained with extremely high probability. # In other words, it is highly unlikely that two different objects # have the same checksum. # } # # @synopsis # # \arguments{ # \item{object}{The object for which a checksum should be calculated.} # \item{...}{Additional arguments passed to @see "digest::digest".} # } # # \value{ # Returns checksum represented as a @character string. # } # # \details{ # Because \code{getChecksum()} is a generic function, # it is possible to provide custom methods for specific # classes of objects. This means that, if a certain class # specifies fields that carry auxiliary data, then these # can be excluded from the checksum calculation. # For instance, assume that all objects of class 'TimestampedObject' # contain timestamps specifying when each object was created. # Then a custom \code{getChecksum()} method for this class can # first drop the timestamp and then call the default # \code{getChecksum()} function. # } # # @author # # \seealso{ # Internally, the @see "digest::digest" method is used to calculate # the checksum. # } # # @keyword "programming" # @keyword "IO" # @keyword "internal" #*/######################################################################### setMethodS3("getChecksum", "default", function(object, ...) { digest(object, ...) }) R.cache/R/options.R0000644000176200001440000000255113572460205013543 0ustar liggesusers#########################################################################/** # @RdocDocumentation "Options used by R.cache" # # \description{ # Below are all \R options specific to the \pkg{R.cache} package. # \cr # \emph{WARNING: Note that the names and the default values of # these options may change in future versions of the package. # Please use with care until further notice.} # } # # \section{Options for controlling futures}{ # \describe{ # \item{\option{R.cache.compress}:}{ # If @TRUE, @see saveCache will write compressed cache files, # otherwise not. # (Default: @FALSE) # } # # \item{\option{R.cache.enabled}:}{ # If @TRUE, @see loadCache is reading from and @see saveCache is writing # to the cache, otherwise not. # (Default: @TRUE) # } # # \item{\option{R.cache.rootPath}:}{ # A @character string specifying the default cache root path. # If not set, environment variable \env{R_CACHE_ROOTPATH} is considered. # } # # \item{\option{R.cache.touchOnLoad}:}{ # If @TRUE, @see loadCache will update the "last-modified" timestamp of # the cache file (to the current time), otherwise not. # (Default: @FALSE) # } # } # } # # \keyword{internal} # \alias{R.cache.options} # # @keyword "programming" # @keyword "IO" #*/######################################################################### NULL R.cache/R/getCacheRootPath.R0000644000176200001440000000447513572460205015243 0ustar liggesusers#########################################################################/** # @RdocDefault getCacheRootPath # # @title "Gets the root path to the file cache directory" # # \description{ # @get "title". # } # # @synopsis # # \arguments{ # \item{defaultPath}{The default path, if no user-specified directory # has been given.} # \item{...}{Not used.} # } # # \value{ # Returns the path as a @character string. # } # # \examples{ # print(getCacheRootPath()) # } # # @author # # \seealso{ # Too set the directory where cache files are stored, # see @see "setCacheRootPath". # } # # @keyword "programming" # @keyword "IO" #*/######################################################################### setMethodS3("getCacheRootPath", "default", function(defaultPath=NULL, ...) { # Check for option settings path <- getOption("R.cache.rootPath", Sys.getenv("R_CACHE_ROOTPATH", "")) if (nchar(path) == 0L) path <- NULL # Backward compatibility if (is.null(path)) { if (is.null(path)) { path <- getOption("R.cache::rootPath") if (!is.null(path)) .Defunct(msg = "R.cache option 'R.cache::rootPath' has been renamed to 'R.cache.rootPath'") } if (is.null(path)) { path <- getOption("R.cache.path") if (!is.null(path)) .Defunct(msg = "R.cache option 'R.cache::path' has been renamed to 'R.cache.rootPath'") } # Check for system environment settings if (is.null(path)) { path <- Sys.getenv("R_CACHE_PATH") if (nzchar(path)) .Defunct(msg = "R.cache environment variable 'R_CACHE_PATH' is deprecated. Use option 'R.cache.rootPath' instead") } if (nchar(path) == 0L) { path <- NULL } if (!is.null(path)) { warning("Use setCacheRootPath() to set the cache path in R.cache.") } } # Otherwise, use argument 'defaultPath'. if (is.null(path)) { if (!is.null(defaultPath)) path <- getDefaultCacheRootPath(defaultPath) } path }) getDefaultCacheRootPath <- function(defaultPath = NULL) { if (is.null(defaultPath)) { ## BACKWARD COMPATIBILITY: For users that already has a ~/.Rcache folder, ## we will use that as the default in order for them not to loose their ## existing cache defaultPath <- "~/.Rcache" if (isDirectory(defaultPath)) return(defaultPath) defaultPath <- getOSCacheRootPath() } defaultPath }R.cache/R/addMemoization.R0000644000176200001440000000365313572460205015020 0ustar liggesusers#########################################################################/** # @RdocDefault addMemoization # # @title "Creates a copy of an existing function such that its results are memoized" # # \description{ # @get "title". # } # # @synopsis # # \arguments{ # \item{fcn}{A @function (or the name of a function) that should be # copied and have memoization added.} # \item{envir}{The @environment from where to look for the function.} # \item{...}{Additional arguments for controlling the memoization, # i.e. all arguments of @see "memoizedCall" that are not passed # to @see "base::do.call".} # } # # \value{ # Returns a @function. # } # # \details{ # The new function is setup such that the the memoized call is done # in the environment of the caller (the parent frame of the function). # # If the @function returns @NULL, that particular function call is # \emph{not} memoized. # } # # @author # # \seealso{ # The returned function utilized @see "memoizedCall" internally. # } # # @keyword "programming" # @keyword "IO" #*/######################################################################### setMethodS3("addMemoization", "default", function(fcn, envir=parent.frame(), ...) { # Argument 'fcn': if (is.character(fcn)) { if (!exists(fcn, mode="function", envir=envir, inherits=TRUE)) { throw("Argument 'fcn' is not an existing function: ", fcn) } fcn <- get(fcn, mode="function", envir=envir, inherits=TRUE) } if (!is.function(fcn)) { throw("Argument 'fcn' is not a function: ", mode(fcn)) } # Already memoized? if (inherits(fcn, "MemoizedFunction")) { return(fcn) } # Record the argument specific to memoizedCall(). memArgs <- list(...) res <- function(..., envir=parent.frame()) { args <- list(fcn, ..., envir=envir) args <- c(args, memArgs) do.call(memoizedCall, args=args) } class(res) <- c("MemoizedFunction", class(res)) res }) # addMemoization() R.cache/R/setCacheRootPath.R0000644000176200001440000000160213572460205015244 0ustar liggesusers#########################################################################/** # @RdocDefault setCacheRootPath # # @title "Sets the root path to the file cache directory" # # \description{ # @get "title". # } # # @synopsis # # \arguments{ # \item{path}{The path.} # \item{...}{Not used.} # } # # \value{ # Returns (invisibly) the old root path. # } # # @author # # \seealso{ # @see "getCacheRootPath". # } # # @keyword "programming" # @keyword "IO" #*/######################################################################### setMethodS3("setCacheRootPath", "default", function(path=NULL, ...) { if (is.null(path)) path <- getDefaultCacheRootPath(path) path <- as.character(path) if (!isDirectory(path)) mkdirs(path, mustWork=TRUE) # Add a README.txt file, if missing. .addREADME(to=path) ovalue <- options("R.cache.rootPath"=path) invisible(ovalue) }) # setCacheRootPath() R.cache/R/999.NonDocumentedObjects.R0000644000176200001440000000145613572460205016460 0ustar liggesusers###########################################################################/** # @RdocDocumentation "Non-documented objects" # # % File cache # # % Class Object # @alias getChecksum.Object # # % Misc. # @alias .textPrompt # # \description{ # This page contains aliases for all "non-documented" objects that # \code{R CMD check} detects in this package. # # Almost all of them are \emph{generic} functions that have specific # document for the corresponding method coupled to a specific class. # Other functions are re-defined by \code{setMethodS3()} to # \emph{default} methods. Neither of these two classes are non-documented # in reality. # The rest are deprecated methods. # } # # @author # # @keyword internal #*/########################################################################### R.cache/R/private.assertDigest.R0000644000176200001440000000205213572460205016156 0ustar liggesusers.assertDigest <- function(onDiff=c("error", "warning", "message"), ...) { # Argument 'onDiff': onDiff <- match.arg(onDiff) # Value to validate against d1 <- digest(0) # Get the "truth" ver <- packageVersion("digest") if (ver <= "0.2.3") { d0 <- "78a10a7e5929f8c605f71823203c0dc5" } else if (ver >= "0.3.0") { d0 <- "908d1fd10b357ed0ceaaec823abf81bc" } else { msg <- sprintf("No assertion rule available for digest v%s. Names of cache files might differ between R version and platforms.", ver) warning(msg) return() } # Assert that we get the above results on the current machine. if (!identical(d1, d0)) { msg <- sprintf("Assertion failed: Detected inconsistency in digest::digest(0) (%s != %s) using digest v%s. The effect of this is that the generated cache files will be named differently on this platform/R version than in another.", d1, d0, ver) if (onDiff == "error") { throw(msg) } else if (onDiff == "warning") { warning(msg) } else { message(msg) } } } # .assertDigest() R.cache/R/readCacheHeader.R0000644000176200001440000000530413572460205015017 0ustar liggesusers#########################################################################/** # @RdocDefault readCacheHeader # # @title "Loads data from file cache" # # \description{ # @get "title", which is unique for an optional key object. # } # # @synopsis # # \arguments{ # \item{file}{A filename or a @connection.} # \item{...}{Not used.} # } # # \value{ # Returns a named @list structure with element \code{identifier}, # \code{version}, \code{comment} (optional), \code{sources} (optional), # and \code{timestamp}. # } # # @author # # @examples "../incl/readCacheHeader.Rex" # # \seealso{ # @see "findCache". # @see "loadCache". # @see "saveCache". # } # # @keyword "programming" # @keyword "IO" # @keyword "internal" #*/######################################################################### setMethodS3("readCacheHeader", "default", function(file, ...) { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Validate arguments # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Argument 'file': if (inherits(file, "connection")) { pathname <- sprintf("'%s' [description of the opened connection]", summary(file)$description) } else { pathname <- as.character(file) if (!isFile(pathname)) throw("Argument 'file' is not an existing file: ", pathname) file <- gzfile(pathname, open="rb") on.exit({ if (!is.null(file)) close(file) }) } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Try to load cached object from file connection # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - header <- list() # 1a. Load identifier: id <- readChar(con=file, nchars=64L) if (length(id) == 0L) { throw("Rcache file format error. Read empty header identifier: ", pathname) } pattern <- "^Rcache v([0-9][0-9]*[.][0-9][0-9]*([.][0-9][0-9]*)*).*" if (regexpr(pattern, id) == -1L) { throw("Rcache file format error ('", pathname, "'). Invalid identifier: ", id) } header$identifier <- id # 1b. Get version header$version <- gsub(pattern, "\\1", id) # 1c. Read trailing '\0'. dummy <- readBin(con=file, what=integer(), size=1, n=1) # 2a. Load comment if (compareVersion(header$version, "0.1") > 0L) { nchars <- readBin(con=file, what=integer(), size=4L, n=1L) header$comment <- readChar(con=file, nchars=nchars) } # 2b. Read trailing '\0'. dummy <- readBin(con=file, what=integer(), size=1L, n=1L) # 3. Load sources: sources <- NULL # To please 'codetools' in R v2.6.0 res <- .baseLoad(con=file, ...) header$sources <- res$sources # 4. Load timestamp: res <- .baseLoad(con=file, ...) header$timestamp <- res$timestamp header }) R.cache/R/loadCache.R0000644000176200001440000001177413572460205013722 0ustar liggesusers#########################################################################/** # @RdocDefault loadCache # # @title "Loads data from file cache" # # \description{ # @get "title", which is unique for an optional key object. # } # # @synopsis # # \arguments{ # \item{key}{An optional object from which a hexadecimal hash # code will be generated and appended to the filename.} # \item{sources}{Optional source objects. If the cache object has a # timestamp older than one of the source objects, it will be ignored # and removed.} # \item{suffix}{A @character string to be appended to the end of the # filename.} # \item{removeOldCache}{If @TRUE and the cache is older than the # \code{sources}, the cache file is removed, otherwise not.} # \item{pathname}{The pathname to the cache file. If specified, # arguments \code{key} and \code{suffix} are ignored. Note that # this is only needed in order to read a cache file for which # the key is unknown, for instance, in order to investigate # an unknown cache file.} # \item{dirs}{A @character @vector constituting the path to the # cache subdirectory (of the \emph{cache root directory} # as returned by @see "getCacheRootPath") to be used. # If @NULL, the path will be the cache root path.} # \item{...}{Not used.} # \item{onError}{A @character string specifying what the action is # if an exception is thrown.} # } # # \value{ # Returns an \R object or @NULL, if cache does not exist. # } # # \details{ # The hash code calculated from the \code{key} object is a # 32 characters long hexadecimal MD5 hash code. # For more details, see @see "getChecksum". # } # # @author # # @examples "../incl/loadCache.Rex" # # \seealso{ # @see "saveCache". # } # # @keyword "programming" # @keyword "IO" #*/######################################################################### setMethodS3("loadCache", "default", function(key=NULL, sources=NULL, suffix=".Rcache", removeOldCache=TRUE, pathname=NULL, dirs=NULL, ..., onError=c("warning", "error", "message", "quiet", "print")) { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Validate arguments # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Argument 'onError': onError <- match.arg(onError) if (onError == "print") { .Defunct(msg = "loadCache(..., onError = \"print\") is deprecated and replaced by onError = \"message\"") } ## Skip cache? if (!getOption("R.cache.enabled", TRUE)) return(NULL) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Find cached file # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (is.null(pathname)) pathname <- findCache(key=key, suffix=suffix, dirs=dirs) if (is.null(pathname)) return(NULL) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Try to load cached object from file connection # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (!isFile(pathname)) return(NULL) fh <- gzfile(pathname, open="rb") on.exit({ if (!is.null(fh)) close(fh) }) tryCatch({ header <- readCacheHeader(fh) if (!is.null(sources)) header$sources <- sources timestamp <- NULL attachLocally(header) # Attaches 'timestamp' (and 'sources') if (!is.null(timestamp) && !is.null(sources)) { for (sourcePathname in sources) { if (!is.character(sources)) { warning("No timestamp check of cache was performed. Unsupported type of cache source: ", class(sources)[1]) break } if (!file.exists(sourcePathname)) { warning("No timestamp check of cache was performed. Source file not found: ", sourcePathname) break } # Is source file newer than cache? lastModified <- file.info(sourcePathname)$mtime if (lastModified > timestamp) { # Remove out-of-date cache file? if (removeOldCache) { close(fh); fh <- NULL file.remove(pathname) } return(NULL) } } # for (sourcePathname in sources) } # 4. Load cached object: res <- .baseLoad(con=fh, ...) object <- res$object res <- NULL # Not needed anymore # 5. Update the "last-modified" timestamp of the cache file? touch <- getOption("R.cache.touchOnLoad") ## Backward compatibility if (is.null(touch)) { touch <- getOption("R.cache::touchOnLoad") if (!is.null(touch)) .Defunct(msg = "R.cache option 'R.cache::touchOnLoad' has been renamed to 'R.cache.touchOnLoad'") } touch <- identical(touch, TRUE) if (touch) { touchFile(pathname) } # 6. Return cached object return(object) }, error = function(ex) { if (onError == "warning") { warning(ex) } else if (onError == "error") { stop(ex) } else if (onError == "message") { message(conditionMessage(ex)) } else if (onError == "print") { print(ex) } }) NULL }) R.cache/R/setupCacheRootPath.R0000644000176200001440000000460214043103161015601 0ustar liggesusers#########################################################################/** # @RdocDefault setupCacheRootPath # # @title "Interactively offers the user to set up the default root path" # # \description{ # @get "title". # } # # @synopsis # # \arguments{ # \item{defaultPath}{Default root path to set.} # \item{...}{Not used.} # } # # \value{ # Returns (invisibly) the root path, # or @NULL if running a non-interactive session. # } # # \details{ # If the cache root path is already set, it is used and nothing is done. # If the "default" root path (\code{defaultPath}) exists, it is used, # otherwise, if running interactively, the user is asked to approve # the usage (and creation) of the default root path. # In all other cases, the cache root path is set to a session-specific # temporary directory. # } # # @author # # \seealso{ # Internally, @see "setCacheRootPath" is used to set the cache root path. # The @see "base::interactive" function is used to test whether \R is # running interactively or not. # } # # @keyword "programming" # @keyword "IO" # @keyword "internal" #*/######################################################################### setMethodS3("setupCacheRootPath", "default", function(defaultPath=NULL, ...) { rootPath <- getCacheRootPath(NULL) # If already set, nothing to do. if (!is.null(rootPath)) { return(invisible(rootPath)) } # Use a temporary root path... rootPath <- file.path(tempdir(), ".Rcache") # unless the default directory exists, ... osDefaultPath <- getDefaultCacheRootPath(NULL) defaultPath <- getDefaultCacheRootPath(defaultPath) if (isDirectory(defaultPath) || identical(defaultPath, osDefaultPath)) { rootPath <- defaultPath } else if (interactive()) { # or we cn ask the user to confirm the default path... prompt <- "The R.cache package needs to create a non-standard directory that will hold cache files." prompt <- c(prompt, sprintf("Do you wish to create the '%s' directory? If not, a temporary directory (%s) that is specific to this R session will be used.", defaultPath, rootPath)) prompt <- paste(prompt, collapse=" ") tryCatch({ ans <- .textPrompt(prompt=prompt, options=c("Y"="yes", "n"="no")) if (ans == "yes") rootPath <- defaultPath }, condition=function(ex) {}) } setCacheRootPath(rootPath) rootPath <- getCacheRootPath() invisible(rootPath) }) # setupCacheRootPath() R.cache/R/memoizedCall.R0000644000176200001440000000450014266246363014461 0ustar liggesusers#########################################################################/** # @RdocDefault memoizedCall # # @title "Calls a function with memoization" # # \description{ # @get "title", that is, caches the results to be retrieved if # the function is called again with the exact same arguments. # } # # @synopsis # # \arguments{ # \item{what}{The @function to be called, or a @character string # specifying the name of the function to be called, # cf. @see "base::do.call".} # \item{...}{Arguments passed to the function.} # \item{envir}{The @environment in which the function is evaluated.} # \item{force}{If @TRUE, any cached results are ignored, otherwise not.} # \item{sources, dirs}{Optional arguments passed to # @see "loadCache" and @see "saveCache".} # } # # \value{ # Returns the result of the function call. # } # # \details{ # If the @function returns @NULL, that particular function call is # \emph{not} memoized. # } # # @author # # \seealso{ # Internally, @see "loadCache" is used to load memoized results, # if available. If not available, then @see "do.call" is used to # evaluate the function call, # and @see "saveCache" is used to save the results to cache. # } # # @keyword "programming" # @keyword "IO" #*/######################################################################### setMethodS3("memoizedCall", "default", function(what, ..., envir=parent.frame(), force=FALSE, sources=NULL, dirs=NULL) { # 1. Generate cache file if (typeof(what) == "closure") { # do not compute the hash from the whole closure, because its internal # state changes over time due to JIT activity (so the logically same # function would get different hashes) key <- list(body = body(what), formals = formals(what), attributes = attributes(what), environment = environment(what), ...) } else { key <- list(what=what, ...) } pathnameC <- generateCache(key=key, dirs=dirs) # 1. Look for memoized results if (!force) { res <- loadCache(pathname=pathnameC, sources=sources) if (!is.null(res)) return(res) } # 2. Otherwise, call method with arguments res <- do.call(what, args=list(...), quote=FALSE, envir=envir) # 3. Memoize results saveCache(res, pathname=pathnameC, sources=sources) # 4. Return results res }) # memoizedCall() R.cache/R/generateCache.R0000644000176200001440000000312713572460205014566 0ustar liggesusers#########################################################################/** # @RdocDefault generateCache # # @title "Generates a cache pathname from a key object" # # \description{ # @get "title". # } # # @synopsis # # \arguments{ # \item{key}{A @list or an @environment from which a @character string # checksum will be calculated and that will constitute the name part # of the cache filename.} # \item{suffix}{A @character string to be appended to the end of the # filename.} # \item{...}{Arguments passed to @see "getCachePath".} # } # # \value{ # Returns the pathname as a @character string. # } # # @author # # \seealso{ # @see "findCache". # Internally, the generic function @see "getChecksum" is used to # calculate the checksum of argument \code{key}. # } # # @keyword "programming" # @keyword "IO" # @keyword "internal" #*/######################################################################### setMethodS3("generateCache", "default", function(key, suffix=".Rcache", ...) { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Validate arguments # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Argument 'key': if (!is.list(key) && !is.environment(key)) { throw("Argument 'key' must be a list, an environment: ", class(key)[1L]) } # Generate cache name from hash code of key object cacheName <- getChecksum(key) # Add cache directory or pathname path <- getCachePath(...) cacheName <- file.path(path, cacheName) # Add suffix cacheName <- paste(cacheName, suffix, sep="") cacheName }, export=TRUE) R.cache/R/000.R0000644000176200001440000000031313572460205012341 0ustar liggesusers## Look for existing generic functions also in imported namespaces. ## This will affect whether setGenericS3() creates a generic function ## or not. options("R.methodsS3:checkImports:setGenericS3"=TRUE) R.cache/R/getCachePath.R0000644000176200001440000000375714254223501014373 0ustar liggesusers#########################################################################/** # @RdocDefault getCachePath # # @title "Gets the path to the file cache directory" # # \description{ # @get "title". # If missing, the directory is created. # } # # @synopsis # # \arguments{ # \item{dirs}{A @character @vector constituting the path to the # cache subdirectory (of the \emph{cache root directory} # as returned by @see "getCacheRootPath") to be used. # If @NULL, the path will be the cache root path.} # \item{path, rootPath}{(Advanced) @character strings specifying the # explicit/default cache path and root cache path.} # \item{...}{Not used.} # } # # \value{ # Returns the path as a @character string. # If the user does not have write permissions to the path, then # an error is thrown. # } # # @author # # \seealso{ # @see "setCachePath". # } # # @keyword "programming" # @keyword "IO" # @keyword "internal" #*/######################################################################### setMethodS3("getCachePath", "default", local({ writable <- list() function(dirs=NULL, path=NULL, rootPath=getCacheRootPath(), ...) { # Get path where to store cache file if (is.null(path)) { # (1) Get/make default path # (a) Get path from options subname <- paste(dirs, collapse="/") name <- paste("R.cache:cachePath", subname, sep=":") path <- getOption(name) # (b) If not availble, make on path <- paste(c(rootPath, dirs), collapse=.Platform$file.sep) } else if (!isAbsolutePath(path)) { # (2) Get/make default path path <- file.path(rootPath, path) } # Create missing directory? if (!isDirectory(path)) { mkdirs(path, mustWork=TRUE) # Add a README.txt file, if missing. .addREADME(to=rootPath) } else { ## Assert if 'path' is writable, unless already checked if (!isTRUE(writable[[path]])) { Arguments$getWritablePath(path) ## throws an error, if not writable[[path]] <<- TRUE } } path }})) # getCachePath() R.cache/R/evalWithMemoization.R0000644000176200001440000000473313572460205016053 0ustar liggesusers#########################################################################/** # @RdocFunction evalWithMemoization # # @title "Evaluates an R expression with memoization" # # \description{ # @get "title" such that the same objects are assigned to the # current environment and the same result is returned, if any. # } # # @synopsis # # \arguments{ # \item{expr}{The @expression to be evaluated.} # \item{key}{Additional objects to uniquely identify the evaluation.} # \item{...}{Additional arguments passed to @see "loadCache" # and @see "saveCache".} # \item{envir}{The @environment in which the expression should # be evaluated.} # \item{drop}{@character vector of \code{expr} attributes to drop. # The default is to drop all source-reference information.} # \item{force}{If @TRUE, existing cached results are ignored.} # } # # \value{ # Returns the value of the evaluated \code{expr} @expression, if any. # } # # @examples "../incl/evalWithMemoization.Rex" # # @author # # \seealso{ # Internally, @see "base::eval" is used to evaluate the expression. # } # # @keyword "programming" # @keyword "IO" #*/######################################################################### evalWithMemoization <- function(expr, key=NULL, ..., envir=parent.frame(), drop=c("srcref", "srcfile", "wholeSrcref"), force=FALSE) { expr <- substitute(expr) for (name in drop) attr(expr, name) <- NULL # Setup a unique list of keys key <- c(list(expr=expr), key) # Look for cached results resList <- loadCache(key=key, ...) if (!force && !is.null(resList)) { # Attach all objects memoized during the evaluation attachLocally(resList$envir, envir=envir) # Return the results of the memoized evaluation return(resList$results) } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Evaluate expression # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Evaluate the expression in a temporary environment, so that # we memoize all objects created along with the results. env <- new.env(parent=envir) res <- eval(expr, envir = env, enclos = baseenv()) # NOTE: For some unknown reason does attachLocally() set # the fields inside 'env' to NULL. /HB 2011-04-02 fields <- ls(envir=env, all.names=TRUE) for (field in fields) { assign(field, get(field, envir=env), envir=envir) } # Cache results resList <- list(envir=env, results=res) saveCache(resList, key=key, ...) res } # evalWithMemoization() R.cache/R/Object.getChecksum.R0000644000176200001440000000023013572460205015507 0ustar liggesuserssetMethodS3("getChecksum", "Object", function(object, ...) { object <- clearCache(object) NextMethod("getChecksum", object=object) }, export=FALSE) R.cache/R/findCache.R0000644000176200001440000000240713572460205013714 0ustar liggesusers#########################################################################/** # @RdocDefault findCache # # @title "Locates a cache file" # # \description{ # @get "title" from a key object. # } # # @synopsis # # \arguments{ # \item{key}{An optional object from which a hexadecimal hash # code will be generated and appended to the filename.} # \item{...}{Additional argument passed to @see "generateCache".} # } # # \value{ # Returns the pathname as a @character, or @NULL if the no cached # data exists. # } # # @author # # \seealso{ # @see "generateCache". # @see "loadCache". # } # # @keyword "programming" # @keyword "IO" # @keyword "internal" #*/######################################################################### setMethodS3("findCache", "default", function(key=NULL, ...) { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Generate cache name from basename and hash object. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - pathname <- generateCache(key=key, ...) if (file.exists(pathname) && !file.info(pathname)$isdir) { return(pathname) } pathnameT <- sprintf("%s.gz", pathname) if (file.exists(pathnameT) && !file.info(pathnameT)$isdir) { return(pathnameT) } return(NULL) }) R.cache/NEWS.md0000755000176200001440000004106314266250643012632 0ustar liggesusers# Version 0.16.0 [2022-07-21] ## New Features * Now `getCachePath()` asserts that the user has write permissions to the cache path. If not, an error is produced. Previously, this check was only done when the cache folder did not exist and had to be created. Now it also checked pre-existing folders. For performance reasons, this check is only done once per R session. ## Bug Fixes * `memoizeCall()` would not always find previously cached results, because R's just-in-time (JIT) compiler could cause the internal state of the memomized function to change. Thanks to Tomas Kalibera for reporting on this and proposing the fix (already back in 2017). # Version 0.15.0 [2021-04-27] ## Significant Changes * The location of the root cache folder as introduced in **R.cache** 0.14.0 has been updated to match that of `tools::R_user_dir()`, which was introduced in R 4.0.0. On Linux, this was already the case in **R.cache** 0.14.0, whereas on macOS and MS Windows, the folder locations have changed slightly. If an old cache folder location is detected, then the user will be queried what action to take, i.e. abort, ignore the old folder, remove the old folder, or move the old folder to the new location. In non-interactive mode, the default action is always to ignore. * The package will no longer ask for permission to create the cache folder as long as the cache folder is compatible with `tools::R_user_dir()`. # Version 0.14.0 [2019-12-05] ## Significant Changes * Now **R.cache** uses a default cache path that adheres to the standard cache location on the current operating system, whereas in previous versions it defaulted to `~/.Rcache`. On Unix, the 'XDG Base Directory Specification' is followed, which means that the **R.cache** folder will typically be `~/.cache/R/R.cache/`. On macOS, it will be `~/Library/Caches/R/R.cache/`. On modern versions of Microsoft Windows, environment variables such as `LOCALAPPDATA` will be used, which typically resolves to `%USERPROFILE%/AppData/Local`, e.g. `C:/Users/alice/AppData/Local`. If **R.cache** fails to find a proper OS-specific cache folder, it will fall back to using `~/.Rcache` as previously done. Importantly, if `~/.Rcache` already exists, then that will be used by default. This is done in order to not lose previously cached files. Users with an existing folder who wish to move to the new standard need to move or remove the `~/.Rcache` folder manually. ## New Features * Add `generateCache()` to generate cache pathnames from a key without creating the cache file. This function was previously not exported. * Option `R.cache.rootPath` now defaults to environment variable `R_CACHE_ROOTPATH` if it is set. * `evalWithMemoization()` gained argument `drop` to specify which attributes to drop from the expression object. The default is to now drop any source-reference attributes. ## Bug Fixes * `evalWithMemoization(expr)` failed to memoize in **knitr** documents because although the same `expr` was specified they differed internally due to source-reference attributes. * `evalWithMemoization()` used partial dollar name matching in one place. ## Deprecated & Defunct * Previously deprecated options `R.cache::rootPath`, `R.cache::touchOnLoad`, and `R.cache::compress` are now defunct. Likewise, environment variable `R_CACHE_PATH` and argument `onError="print"` for `loadCache()` are now defunct. ## Software Quality * Now a temporary cache root path is always set when running `R CMD check`, unless one is explicitly set via an option or an environment variable. # Version 0.13.0 [2018-01-03] ## Significant Changes * Package now formally requires R (>= 2.14.0) released October 2011. ## New Features * Now package gives a more informative error message in the rare cases it fails to create the cache root directory or fails to save a cache file. * Updated `loadCache()` to recognize new file-format version 3 coming to R. * Added options `R.cache.enabled`, which defaults to TRUE, for controlling whether `loadCache()` and `saveCache()` should read/write from cache or not. This provides an easy mechanism for temporarily disabling **R.cache**. * Harmonized **R.cache** options to all have names prefixed with `R.cache.`. * `clearCache()` now prompts the user via `readline()`, which is always visible, i.e. it can neither be captured nor sinked. ## Software Quality * TESTS: Increased test coverage. ## Deprecated & Defunct * Using `onError = "print"` for `loadCache()` is deprecated and replaced by new `onError = "message"`. * Deprecated **R.cache** options `R.cache::rootPath`, `R.cache::touchOnLoad`, and `R.cache::compress`. Use `R.cache.rootPath`, `R.cache.touchOnLoad`, and `R.cache.compress` instead. # Version 0.12.0 [2015-11-12] ## New Features * Now all prompt and verbose messages are send to the standard error (instead of the standard output). * SPEEDUP: Now `memoizedCall()` generates cache pathname only once. ## Software Quality * TESTS: Increased test coverage from 64% to 86%. ## Deprecated & Defunct * CLEANUP: Dropped argument `verbose` from `memoizedCall()`. # Version 0.11.1 [2014-09-10] ## Documentation * Clarified in help that function calls that returns ("has value") NULL will not be cached. ## Software Quality * TESTS: Added package system tests for `memoizeCall()` and `addMemoization()`. ## Bug Fixes * `addMemoization()` will no longer memoize an already memoized function. # Version 0.11.0 [2014-09-05] ## Significant Changes * Now package imports rather than suggests the **digest** package. This simplifies installation/usage of the package. # Version 0.10.0 [2014-06-10] ## Software Quality * Bumped package dependencies. # Version 0.9.5 [2014-05-01] ## New Features * The textual prompt used to ask new **R.cache** users for approval on creating a persistent cache directory is now using the standard error (stderr) rather than the standard output (stdout). This lowers the risk for issues with report generators. # Version 0.9.4 [2014-04-26] ## Software Quality * Minimizing the use of `::`. # Version 0.9.3 [2014-01-30] ## Software Quality * Bumped package dependencies. # Version 0.9.2 [2014-01-13] * All call to internal `generateCache()` with `key = NULL` would give a hard-to-understand error message. Now it's more informative. ## Software Quality * Bumped package dependencies. # Version 0.9.1 [2013-12-21] * Added arguments `path` and `rootPath` to `getCachePath()`. * Added argument `pathname` to `saveCache()`. # Version 0.9.0 [2013-10-17] ## Bug Fixes * If the package was only loaded but not attached, the cache root path would default to `~/.Rcache/`, which in turn could cause that path to be create without asking the user. For instance, `R.cache::loadCache(list())` would do. Thanks to Kurt Hornik at Vienna University of Economics and Business for reporting on this. # Version 0.8.4 [2013-10-14] ## Bug Fixes * Adjusted package dependencies and NAMESPACE to work with the package versions available on CRAN. ## Software Quality * Now DESCRIPTION's `Authors` field matches `Authors@R`. # Version 0.8.3 [2013-10-03] ## Software Quality * Bumped package dependencies. # Version 0.8.2 [2013-09-28] ## New Features * Now the `R.cache` `Package` object is also available when the package is only loaded (but not attached). # Version 0.8.1 [2013-09-15] ## Software Quality * Now only importing a minimal set of functions needed from the **R.oo** and the **R.utils** packages. * Bumped package dependencies. # Version 0.8.0 [2013-08-21] ## Significant Changes * Now **R.utils** is no longer attached ("loaded") - only imported. ## Software Quality * TESTS: Added system tests. # Version 0.7.4 [2013-08-20] ## Software Quality * Now explicitly importing one function from **utils** in NAMESPACE. # Version 0.7.3 [2013-08-18] ## Software Quality * Now `clearCache()` is exported (re-exported from **R.oo**). # Version 0.7.2 [2013-08-03] ## Software Quality * Bumped package dependencies. ## Bug Fixes * `R.cache:::.assertDigest()` called from within another package would give an error that `packageVersion()` of **utils** was not found. # Version 0.7.1 [2013-07-11] ## Software Quality * Updated the title and the description of the package. # Version 0.7.0 [2013-07-03] ## New Features * Now `getChecksum()` passes `...` to `digest()`, e.g. argument `algo`. ## Software Quality * Bumped package dependencies. # Version 0.6.10 [2013-05-25] ## Software Quality * Minor speedup of `loadCache()` - replaced an `rm()` call with NULL assignment. # Version 0.6.9 [2013-05-20] ## Software Quality * CRAN POLICY: Now all Rd `\usage{}` lines are at most 90 characters long. * Bumped package dependencies. # Version 0.6.8 [2012-12-19] ## New Features * Utilizing new `startupMessage()` of **R.oo**. # Version 0.6.7 [2012-11-28] ## New Features * Added support for `clearCache(..., recursive = TRUE)`. # Version 0.6.6 [2012-11-27] ## Bug Fixes * `clearCache()` would give error "object 'dirs' not found". # Version 0.6.5 [2012-11-18] ## Significant Changes * Package now only imports **R.methodsS3** and **R.oo**, no long depends (attaches) them. It still needs to load **R.utils**. * Now package exports a smaller set of the methods. ## Software Quality * ROBUSTNESS: Now package declares S3 methods in the namespace. * Added internal `.assertDigest()`, which originates from **aroma.core**. # Version 0.6.4 [2012-10-16] ## Significant Changes * Package now imports **R.methodsS3** and **R.oo**. ## Bug Fixes * ROBUSTNESS: No longer passing `...` to `NextMethod()`, cf. R-devel thread 'Do *not* pass '...' to NextMethod() - it'll do it for you; missing documentation, a bug or just me?' on Oct 16, 2012. # Version 0.6.3 [2012-09-12] ## Significant Changes * Renamed the installed `.Rcache/` directory to `_Rcache/` to avoid `R CMD check` NOTEs. ## Software Quality * CRAN POLICY: Removed one last call to `.Internal()` for loading saved data. This could be done in a backward-compatible way using `readRDS()`. # Version 0.6.2 [2012-03-20] ## Software Quality * CRAN POLICY: Dropped an explicit call to an `.Internal()` function. # Version 0.6.1 [2012-01-22] ## New Features * Updated the README that is copied to the `.Rcache` directory. # Version 0.6.0 [2011-12-30] ## Significant Changes * As before, the cache root path defaults to `~/.Rcache/`. However, if it does not exists, then it is created when the package is loaded, but only after approval by the user (via a textual prompt). If not approved, or it is not possible to prompt the user (e.g. in a non-interactive session), then a session-specific temporary directory is used. # Version 0.5.3 [2011-12-29] ## New Features * Now `getCachePath()` and ``setCacheRootPath()`` add a README.txt file to the root path, iff missing. It explains why the directory structure exists, what created it, and that it is safe to delete. # Version 0.5.2 [2011-10-05] ## Bug Fixes * For R v2.13.0 only: Applying the same fix that was done for R v2.12.2 and before in **R.cache** v0.5.1. # Version 0.5.1 [2011-08-31] ## Bug Fixes * For R v2.12.2 and before: After adding support for compressed files in **R.cache** v0.5.0, we would get the 'Error in seek.connection(con, origin = "current", where = -5) : whence = "end" is not implemented for gzfile connections' in `readCacheHeader()` iff running R v2.12.2 or before. Thanks to Uwe Ligges (R core) for reporting on this. # Version 0.5.0 [2011-08-16] ## New Features * Added support for saving and loading compressed cache files. * Now package uses `packageStartupMessage()` instead of `cat()`. ## Software Quality * ROBUSTNESS: Now `findCache()` asserts that any identified cache file is really a file. # Version 0.4.3 [2011-07-21] ## Documentation * Clarified how argument `dirs` (in methods using it) specifies the subdirectory of the cache root directory. # Version 0.4.2 [2011-05-19] ## New Features * Now argument `prompt` for `clearCache()` defaults to TRUE iff `interactive()` is TRUE, otherwise FALSE. ## Documentation * Added a help page to `clearCache()`. # Version 0.4.1 [2011-04-02] ## New Features * Now `generateCache()` utilizes a generic function `getChecksum()` to obtain the checksum. This makes it possible to customize how checksums are calculated for different classes of objects. * Added a default `getChecksum()` which utilizes `digest::digest()`. * Added `getChecksum()` for the `Object`, which first clears the cache of the object and the calls the default ditto. * Added trial version of `evalWithMemoization()`. ## Bug Fixes * `clearCache()` would also report on subdirectories. # Version 0.4.0 [2011-02-14] ## New Features * Added trial versions of `memoizedCall()` and `addMemoization()`. # Version 0.3.0 [2010-03-13] ## Software Quality * Added a NAMESPACE. # Version 0.2.0 [2009-10-16] ## Bug Fixes * In R v2.10.0 and newer, we would get an error reporting that internal function `loadFromConn()` does not exists. # Version 0.1.9 [2009-09-11] ## New Features * Added argument `onError` to `loadCache()`, to specify the action when an error occurs. The default used to be to print the error message (`onError = "print"`), but now it generates a warning (`"warning"`). The other alternatives are do silently ignore it, or to throw the error (`"error"`). Except for `onError = "error"`, `loadCache()` always returns NULL if an error occurs. # Version 0.1.8 [2009-08-11] ## New Features * Now `readCacheHeader()` reports the "pathname" in error/warnings messages, if argument `file` refers to a file and the "description" if it refers to a connection. ## Software Quality * ROBUSTNESS: Added sanity check to `readCacheHeader()` testing that the read header identifier is non-empty. This results in a clearer error message that before. * Renamed the HISTORY file to NEWS. # Version 0.1.7 [2008-02-27] ## New Features * Added option to updated the "last-modified" timestamp of cache files whenever they are loaded via `loadCache()`. This will help identified what cache files have not been used for a long time. To turn this on, use `options("R.cache::touchOnLoad" = TRUE)`. * Now error messages specifies the pathname, if available. ## Bug Fixes * The `throw()` for invalid identifiers was trying to put the connection object in the output and not the identifier. # Version 0.1.6 [2007-07-02] ## New Features * Now environments, in addition to lists, may be used as keys for generating cache names. ## Software Quality * Package passes `R CMD check` on R v2.6.0 devel. Minor mods. # Version 0.1.5 [2007-03-11] ## New Features * Added `getCacheRootPath()` to the help index page. ## Software Quality * Package passes `R CMD check` on R v2.5.0. # Version 0.1.4 [2007-03-07] ## New Features * Added `getCacheRootPath()` and `setCacheRootPath()` to specify where the root of the file path is located. # Version 0.1.3 [2007-01-24] ## New Features * Now `saveCache()` and `loadCache()` takes optional argument `dirs` for caching data to subdirectories of the root cache directory. * Added `setCacheRootPath()` to set the root cache directory. # Version 0.1.2 [2006-05-25] ## New Features * Added argument `pathname` to `loadCache()` in order to load "unknown" cache files for which the key is unknown. ## Bug Fixes * Work around for not saving "promises" (non-evaluated arguments) in `base::save()`, which otherwise includes all of the surrounding environment if 'sources' is not evaluated/missing. For more details see code and my email to r-devel on 2006-05-25. Thanks to Brian Ripley for explaining what was going on. # Version 0.1.1 [2006-05-22] ## Significant Changes * Added header comment for file format > v0.1. ## New Features * Added `readCacheHeader()`. * Added detection of file format version. # Version 0.1.0 [2005-12-16] ## New Features * Using a special binary file format now. It allows you to check if cache is up-to-date to a source file. If not, the rest of the cache binary file is not loaded. * Added `loadCache()` and `saveCache()` methods. * Created. R.cache/MD50000644000176200001440000000704214266276262012045 0ustar liggesusers9fabae67fff42ee4bb3aa863b43c2bfe *DESCRIPTION ec6242da620a17acb47b4b95c5cabe28 *NAMESPACE 27cb90cac99353f1093e57f128c31df8 *NEWS.md 5b3e0291bcc049d9ada9005162c5259a *R/000.R 302f2b6b2ba00270a9bdd2b9341bda69 *R/999.NonDocumentedObjects.R 839c6eee03ff943e8b677f92b3503c5f *R/999.package.R e17839be623961a11dc4de87f1ee5501 *R/Object.getChecksum.R 47125aebb1741a8ca266f37a3f983b62 *R/addMemoization.R f72086adb62a7f4b1db2b80016b28efd *R/addREADME.R e41b682322d80d8875442e6b1ed44980 *R/clearCache.R 593da10e730f1f58568e32af1eff9858 *R/evalWithMemoization.R aaf4ac01144842c09257dcac5e77aac3 *R/findCache.R 7843ab7b7a9b001c78e0eb8f95e4affb *R/generateCache.R b272c2a5816689bfcfae100af3933cc7 *R/getCachePath.R 2f52fb9ef27614dfc9797044f71db6de *R/getCacheRootPath.R d0e2db7befdc75d6570375a1430a542c *R/getChecksum.R 4a3722a663e3798e8a81936ce7a6ae4c *R/getOSCacheRootPath.R dfd2aa8333a0c27a36ad43b43569ae9e *R/loadCache.R e4f44ace79c3e10b23ab6f1a9b9aa2a3 *R/memoizedCall.R b7bdc2ef7de91f265d058dcc1e4c3f1c *R/options.R 01fb7e9517d9726e699897a9426637b6 *R/private.assertDigest.R 8a62fe4edf1c17b6b3a6baa0d926846f *R/private.baseLoad.R fdca06bd7994e9baf33f2fda4288d445 *R/queryRCmdCheck.R df1bb7fb52cc77d7a179ce4ee0bcb1a5 *R/readCacheHeader.R d3128f009056f915fd2fdcb8e74a2680 *R/saveCache.R 562e95b1cb12d505d0d6191d82ca4b92 *R/setCachePath.R bc2ae80ef26e74cee63f37dfeed6ede4 *R/setCacheRootPath.R ed17a4c3a294d23bb234ccf80ad7ba1b *R/setupCacheRootPath.R 56385ff3d1eca1603dc7b3dd42b66b5f *R/textPrompt.R 72df982411d6930835afb15bd868ffed *R/zzz.R ea404c4968560bf4f5eaac3f63126d74 *inst/WORDLIST 42b71ea60b7c385ad29633002f402f72 *inst/_Rcache/README.txt 3311c145782d7ec6f6d689d589831248 *man/000.baseLoad.Rd 894d7db8c84876186c5e4a15e882d7d3 *man/Non-documented_objects.Rd 323690001acb43c851dc865a311e24d8 *man/Options_used_by_R.cache.Rd d7d45e768f149c07472a0c46ac852471 *man/R.cache-package.Rd f9f1d84d2e8c58014918c1ae97a81bb5 *man/addMemoization.Rd da7b453ab09818cd4d60ce674cd053cb *man/clearCache.Rd ef96850463967441aee32a86ca3bc090 *man/evalWithMemoization.Rd bf95ebc08e60b9d72cf01959b1dd569d *man/findCache.Rd b5b2cbf8b7f5387ecc3422219e573d4f *man/generateCache.Rd e9f4d288251384e19ab9707aa1b4b054 *man/getCachePath.Rd 1169f1088886553f9b9410013c8bc894 *man/getCacheRootPath.Rd 84053d18586b1a366e7a3a632c730fb6 *man/getChecksum.Rd 9acc185d37c9adc1e1aa2abf3b4759a0 *man/loadCache.Rd 053307070f1bce8506933196b244ff2e *man/memoizedCall.Rd 184fd1c1c5a37f4edce5b3cfbcb9c710 *man/readCacheHeader.Rd 47ab7fb7c780a89d06c337804ee67b2b *man/saveCache.Rd d00470f6de38631a9420e4c37937293d *man/setCachePath.Rd dd3edd06eda0a471db06956188c01605 *man/setCacheRootPath.Rd 62419cc6e4442fabf2e910f1ab266ed4 *man/setupCacheRootPath.Rd 163379131b9fe370e4fb7e4b5269cfd5 *tests/DEPRECATED.R 6ce2813e0d03bb345b401a0d378fd5c2 *tests/Object.getChecksum.R c1e1538550c04359740b7dc838ed6fe9 *tests/StaticMethodsAndNamespaces.R e4ff692889bf77f46e6341daf8833d5a *tests/addMemoization.R 2820694bdf621d311b3c6a2ff5e97e08 *tests/assertDigest.R 7e652589f322288434c2282b6f6403b0 *tests/clearCache.R bd58e9bfd6bfef4e05df2dcee613be39 *tests/evalWithMemoization.R 4b0def314df91330542cec7aef6f94a6 *tests/findOSCachePath.R 28a582fc86c1a5e4c06e9fbda16bea48 *tests/getCachePath.R 50eb00c3770d4d10dff9a1e97563223c *tests/getCacheRootPath.R 20467dffbe05556670964c2cf40d5f8f *tests/loadCache.R d93ca48624afe21010017a48c924a8bb *tests/memoizedCall.R 09448a5eb75b57e414d3eaaccca84a22 *tests/readCacheHeader.R 7fe53d98d828cf1b780b8d5b97221e79 *tests/setCachePath.R ee59ebbd08ca1ca9f26844a901bab20c *tests/setCacheRootPath.R 077c42378e238c54fe133f611daae293 *tests/textPrompt.R R.cache/inst/0000755000176200001440000000000013572460205012476 5ustar liggesusersR.cache/inst/_Rcache/0000755000176200001440000000000013340347143014020 5ustar liggesusersR.cache/inst/_Rcache/README.txt0000644000176200001440000000065713340347143015526 0ustar liggesusersThis directory structure was created by the R package 'R.cache' available on CRAN [https://cran.r-project.org/package=R.cache]. It holds cache files containing results memoized by various R packages that utilize the R.cache package. It is safe to delete all or part of these files at any time. By definition, if memoized results are missing, they are recalculated by the R package who needs them/created them in the first place. R.cache/inst/WORDLIST0000644000176200001440000000024713572460205013673 0ustar liggesusersAchim AppVeyor CMD DSC Friedrich getCacheRootPath gz gzip Hornik Leisch loadCache macOS memoization Memoization memoized oo pre Pre TimestampedObject Wishlist Zeileis