Description Usage Arguments Value Examples
View source: R/cacheManagement.R
If cacheDir
takes up more than maxCacheSize
megabytes on disk, files wll be removed in order of oldest access time. Only
files matching extensions
are eligible for removal.
1 2 | manageCache(cacheDir, extensions = c("html", "json", "pdf", "png"),
maxCacheSize = 100)
|
cacheDir |
location of cache directory |
extensions |
vector of file extensions eligible for removal |
maxCacheSize |
maximum cache size in megabytes |
Invisibly returns the number of files removed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Create a cache directory and fill it with 1.6 MB of data
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, full.names=TRUE)) {
print(file.info(file)[,c(1,6)])
}
# Remove files based on last access time until we get under 1 MB
manageCache(CACHE_DIR, extensions='csv', maxCacheSize=1)
for (file in list.files(CACHE_DIR, full.names=TRUE)) {
print(file.info(file)[,c(1,6)])
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.