CACHE_DIR <- tempdir()
write.csv(matrix(1, 400, 500), file = file.path(CACHE_DIR, "m1.csv"))
write.csv(matrix(2, 400, 500), file = file.path(CACHE_DIR, "m2.csv"))
write.csv(matrix(3, 400, 500), file = file.path(CACHE_DIR, "m3.csv"))
write.csv(matrix(4, 400, 500), file = file.path(CACHE_DIR, "m4.csv"))
for (file in list.files(CACHE_DIR, pattern = "\\.csv$", full.names = TRUE)) {
print(file.info(file)[, c("size", "mtime")])
}
# Remove files based on access time until the cache is under 1 MB
manageCache(
CACHE_DIR,
extensions = "csv",
maxCacheSize = 1,
sortBy = "atime"
)
for (file in list.files(CACHE_DIR, pattern = "\\.csv$", full.names = TRUE)) {
print(file.info(file)[, c("size", "mtime")])
}
Run the code above in your browser using DataLab