This is still very experimental. See examples.

cloudCache(..., useCloud = getOption("reproducible.useCloud", TRUE),
  checksumsFileID = NULL, cloudFolderID = NULL)



Passed to Cache


Logical. This allows this to be turned off; will send all arguments to Cache (including possibly useCache, where all caching can be turned off)


A google file ID where the checksums data.table is located, provided as a character string.


The google folder ID where a new checksums file should be written. This will only be used if checksumsFileID is not provided provided as a character string.


This has Cache internally. The main goal of this function is to look at local Cache first, if the object is there locally, then use it & upload it to googledrive. If the object is not there locally, check on googledrive for the object. If it is there, download it, then add it to the local Cache. If it is not there, then run the function de novo, wrapped in Cache and upload the object to googledrive (i.e., it will be in local Cache and cloud location).


This is essentially a wrapper around Cache, so it will still use the local Cache.

See also


# Make a folder on googledrive -- share it with yourself and anybody else -- either use
#   googledrive package or do this manually on
# Grab the share link -- pass it here to cloudFolderID

# first time -- looks in cloudFolderID for checksums -- none there, so it makes it
#   then it runs the function, caching locally, and uploading to cloud -- copy exists in
#   2 places
newDir <- drive_mkdir("testFolder")
a1 <- cloudCache(rnorm, 1, cloudFolderID = newDir$id)
# second time -- sees that it is in both places, takes local
a2 <- cloudCache(rnorm, 1, cloudFolderID = newDir$id)

# clear local -- get from cloud copy, make a local copy in cacheRepo
clearCache(ask = FALSE)
a3 <- cloudCache(rnorm, 1, cloudFolderID = newDir$id)

# now both local and cloud exist
a4 <- cloudCache(rnorm, 1, cloudFolderID = newDir$id)

#  more than one cacheRepo
opts <- options("reproducible.cachePath" = c(tempdir(), file.path(tempdir(), "test"),
                                             file.path(tempdir(), "test2")),
                "reproducible.ask" = FALSE)
cachePaths <- getOption("reproducible.cachePath")
Cache(rnorm, 4, cacheRepo = cachePaths[3]) # put it in 3rd cacheRepo

# gets it locally even though it is in the 3rd cacheRepo, uploads to cloudCache
cloudCache(rnorm, 4, cloudFolderID = newDir$id)

# Clean up -- also see cloudSyncCache
clearCache(ask = FALSE)
# lapply(cachePaths, clearCache, ask = FALSE)
cloudSyncCache(cloudFolderID = newDir$id)

# }