BiodbPersistentCache | R Documentation |
The abstract class for handling file caching.
The abstract class for handling file caching.
This abstract class is the mother class of concrete classes that manage cache systems for saving downloaded files and request results.
It is designed for internal use, but you can still access some of the read-only methods if you wish.
new()
New instance initializer. Persistent cache objects must not be created directly. Instead, access the cache instance through the BiodbMain instance using the getPersistentCache() method.
BiodbPersistentCache$new(cfg, bdb = NULL)
cfg
An instance of the BiodbConfig class.
bdb
An instance of the BiodbMain class.
Nothing.
isReadable()
Checks if the cache system is readable.
BiodbPersistentCache$isReadable(conn = NULL)
conn
If not \codeNULL, checks if the cache system is readable for this particular connector.
\codeTRUE if the cache system is readable, \codeFALSE otherwise.
isWritable()
Checks if the cache system is writable.
BiodbPersistentCache$isWritable(conn = NULL)
conn
If not \codeNULL, checks if the cache system is writable for this particular connector.
\codeTRUE if the cache system is writable, \codeFALSE otherwise.
getDir()
Gets the path to the persistent cache folder.
BiodbPersistentCache$getDir()
The path to the cache folder as a character value.
getFolderPath()
Gets path to the cache system sub-folder dedicated to this cache ID.
BiodbPersistentCache$getFolderPath(cache.id, create = TRUE, fail = FALSE)
cache.id
The cache ID to use.
create
If set to TRUE and the folder does not exist, creates it.
fail
If set to TRUE, throws a warning if the folder does not exist.
A string containing the path to the folder.
folderExists()
Tests if a cache folder exists for this cache ID.
BiodbPersistentCache$folderExists(cache.id)
cache.id
The cache ID to use.
TRUE if a cache folder exists.
getFilePath()
Gets path of file in cache system.
BiodbPersistentCache$getFilePath(cache.id, name, ext)
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files.
A character vector, the same size as \codenames, containing the paths to the files.
filesExist()
Tests if at least one cache file exist for the specified cache ID.
BiodbPersistentCache$filesExist(cache.id)
cache.id
The cache ID to use.
A single boolean value.
fileExist()
DEPRECATED. Use fileExists().
BiodbPersistentCache$fileExist(cache.id, name, ext)
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files, without the dot (\"html\", \"xml\", etc).
A logical vector, the same size as \codename, with \codeTRUE value if the file exists in the cache, or \codeFALSE otherwise.
fileExists()
Tests if a particular file exist in the cache.
BiodbPersistentCache$fileExists(cache.id, name, ext)
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files, without the dot (\"html\", \"xml\", etc).
A logical vector, the same size as \codename, with \codeTRUE value if the file exists in the cache, or \codeFALSE otherwise.
markerExist()
DEPRECATED. Use markerExists().
BiodbPersistentCache$markerExist(cache.id, name)
cache.id
The cache ID to use.
name
A character vector containing marker names.
A logical vector, the same size as \codename, with \codeTRUE value if the marker file exists in the cache, or \codeFALSE otherwise.
markerExists()
Tests if markers exist in the cache. Markers are used, for instance, by biodb to remember that a downloaded zip file from a database has been extracted correctly.
BiodbPersistentCache$markerExists(cache.id, name)
cache.id
The cache ID to use.
name
A character vector containing marker names.
A logical vector, the same size as \codename, with \codeTRUE value if the marker file exists in the cache, or \codeFALSE otherwise.
setMarker()
Sets a marker.
BiodbPersistentCache$setMarker(cache.id, name)
cache.id
The cache ID to use.
name
A character vector containing marker names.
Nothing.
getTmpFolderPath()
Gets path to the cache system temporary folder.
BiodbPersistentCache$getTmpFolderPath()
A string containing the path to the folder.
getUsedCacheIds()
Returns a list of cache IDs actually used to store cache files.
BiodbPersistentCache$getUsedCacheIds()
A character vector containing all the cache IDs actually used inside the cache system.
loadFileContent()
Loads content of files from the cache.
BiodbPersistentCache$loadFileContent( cache.id, name, ext, output.vector = FALSE )
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files.
output.vector
If set to \codeTRUE, force output to be a \codevector instead of a \codelist. Where the list contains a \codeNULL, the \codevector will contain an \codeNA value.
A list (or a vector if \codeoutput.vector is set to \codeTRUE), the same size as \codename, containing the contents of the files. If some file does not exist, a \codeNULL value is inserted inside the list.
saveContentToFile()
Saves content to files into the cache.
BiodbPersistentCache$saveContentToFile(content, cache.id, name, ext)
content
A list or a character vector containing the contents of the files. It must have the same length as \codename.
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files.
Nothing.
addFilesToCache()
Adds exisiting files into the cache.
BiodbPersistentCache$addFilesToCache( src.file.paths, cache.id, name, ext, action = c("copy", "move") )
src.file.paths
The current paths of the source files, as a character vector.
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files.
action
Specifies if files have to be moved or copied into the cache.
Nothing.
copyFilesIntoCache()
Copies exisiting files into the cache.
BiodbPersistentCache$copyFilesIntoCache(src.file.paths, cache.id, name, ext)
src.file.paths
The current paths of the source files, as a character vector.
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files.
Nothing.
moveFilesIntoCache()
Moves exisiting files into the cache.
BiodbPersistentCache$moveFilesIntoCache(src.file.paths, cache.id, name, ext)
src.file.paths
The current paths of the source files, as a character vector.
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files.
Nothing.
erase()
Erases the whole cache.
BiodbPersistentCache$erase()
Nothing.
deleteFile()
Deletes a list of files inside the cache system.
BiodbPersistentCache$deleteFile(cache.id, name, ext)
cache.id
The cache ID to use.
name
A character vector containing file names.
ext
The extension of the files, without the dot (\"html\", \"xml\", etc).
Nothing.
deleteAllFiles()
Deletes, in the cache system, all files associated with this cache ID.
BiodbPersistentCache$deleteAllFiles(cache.id, fail = FALSE, prefix = FALSE)
cache.id
The cache ID to use.
fail
If set to TRUE, a warning will be emitted if no cache files exist for this cache ID.
prefix
DEPRECATED If set to TRUE, use cache.id as a prefix, deleting all files whose cache.id starts with this prefix.
Nothing.
deleteFiles()
Deletes all files with the specific extension of the cache ID in the cache system.
BiodbPersistentCache$deleteFiles(cache.id, ext)
cache.id
The cache ID to use.
ext
The extension of the files, without the dot (\"html\", \"xml\", etc). Only files having this extension will be deleted.
Nothing.
listFiles()
Lists files present in the cache system.
BiodbPersistentCache$listFiles( cache.id, ext = NULL, extract.name = FALSE, full.path = FALSE )
cache.id
The cache ID to use.
ext
The extension of the files, without the dot (\"html\", \"xml\", etc).
extract.name
If set to \codeTRUE, instead of returning the file paths, returns the list of names used to construct the file name: [cache_folder]/[cache.id]/[name].[ext].
full.path
If set to \codeTRUE, returns full path for files.
The files of found files, or the names of the files if \codeextract.name is set to \codeTRUE.
print()
Displays information about this object.
BiodbPersistentCache$print()
enabled()
DEPRECATED method. Use now \codeBiodbConfig :isEnabled('cache.system').
BiodbPersistentCache$enabled()
enable()
DEPRECATED method. Use now \codeBiodbConfig :enable('cache.system').
BiodbPersistentCache$enable()
disable()
DEPRECATED method. Use now \codeBiodbConfig :disable('cache.system').
BiodbPersistentCache$disable()
clone()
The objects of this class are cloneable with this method.
BiodbPersistentCache$clone(deep = FALSE)
deep
Whether to make a deep clone.
BiodbMain
, BiodbBiocPersistentCache
,
BiodbBiocPersistentCache
.
# Create an instance with default settings: mybiodb <- biodb::newInst() # Get a compound CSV file database chebi.tsv <- system.file("extdata", "chebi_extract.tsv", package='biodb') # Get a connector instance: conn <- mybiodb$getFactory()$createConn('comp.csv.file', url=chebi.tsv) # Get all entries entries <- conn$getEntry(conn$getEntryIds()) # Get the cache instance: cache <- mybiodb$getPersistentCache() # Get list of files inside the cache: files <- cache$listFiles(conn$getCacheId()) # Delete files inside the cache: cache$deleteAllFiles(conn$getCacheId()) # Terminate instance. mybiodb$terminate()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.