This hidden function appends a single tag (key-value pair) to the metadata
of a cached object identified by its cacheId. Tags can be stored either in
a database (via DBI) or in a file-based cache system.
Updates the value of an existing tag for a cached object identified by its
cacheId. If the tag does not exist and add = TRUE, the tag will be added.
This function supports both database-backed and file-based cache systems.
.addTagsRepo(
cacheId,
cachePath = getOption("reproducible.cachePath"),
tagKey = character(),
tagValue = character(),
cacheSaveFormat = getOption("reproducible.cacheSaveFormat"),
drv = getDrv(getOption("reproducible.drv", NULL)),
conn = getOption("reproducible.conn", NULL)
)
.updateTagsRepo(
cacheId,
cachePath = getOption("reproducible.cachePath"),
tagKey = character(),
tagValue = character(),
add = TRUE,
cacheSaveFormat = getOption("reproducible.cacheSaveFormat"),
drv = getDrv(getOption("reproducible.drv", NULL)),
conn = getOption("reproducible.conn", NULL)
)character(1)
Unique identifier of the cached object. Must be of length 1.
character(1)
Path to the cache directory. Defaults to getOption("reproducible.cachePath").
character(1)
The key for the tag. Must be supplied.
character(1)
The new value for the tag. Must be supplied.
character(1)
Format used for saving cache files. Defaults to getOption("reproducible.cacheSaveFormat").
A DBI driver object. Defaults to getDrv(getOption("reproducible.drv", NULL)).
A DBI connection object. If NULL, a new connection is created internally.
logical(1)
If TRUE, adds the tag if it does not exist. Defaults to TRUE.
NULL (invisibly). The function is called for its side effects.
NULL (invisibly). Called for its side effects.
This function is primarily used internally by the reproducible package to
maintain metadata about cached objects. It supports both database-backed and
file-based caching systems.
If useDBI() returns TRUE, the tag update is performed in the database table.
If no rows are affected and add = TRUE, the tag is inserted using .addTagsRepo().
For file-based caches, the function modifies the tag in the corresponding metadata file.
.addTagsRepo() for adding tags without updating.
if (FALSE) { # \dontrun{
a <- Cache(rnorm(1))
.addTagsRepo(cacheId = gsub("cacheId:", "", attr(a, "tags")),
tagKey = "status", tagValue = "processed")
showCache() # last entry is the above line
} # }
if (FALSE) { # \dontrun{
a <- Cache(rnorm(1))
# Update an existing tag
.updateTagsRepo(cacheId = gsub("cacheId:", "", attr(a, "tags")),
tagKey = "status", tagValue = "second")
# Add a tag if it doesn't exist
.updateTagsRepo(cacheId = gsub("cacheId:", "", attr(a, "tags")),
tagKey = "status", tagValue = "new", add = TRUE)
} # }