# NOT RUN {
# Make a folder on googledrive -- share it with yourself and anybody else -- either use
# googledrive package or do this manually on drive.google.com
# 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
library(googledrive)
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)
# }
Run the code above in your browser using DataLab