Checks for the existence of cached XML files in the cache directory. Can check for files for a specific department, academic year, or combination of both. If no filters are specified, checks if any cache files exist.
Arguments
- name
Character string. Optional department code (e.g.,
"CS") to check for specific department cache files.- year
Character string. Optional academic year in
YYYYYYYYformat (e.g.,"20232024") to check for cache files from a specific year.- cache_dir
Character string. Optional path to the cache directory. If
NULL, uses the default cache location.
Value
A logical value:
TRUEif matching cache files existFALSEif no matching files found or if check fails
Details
The function supports three checking modes based on parameter combinations:
Department-specific: When
nameis providedChecks for:
"{name}.xml"or"{name}_{year}.xml"if year provided
Year-specific: When only
yearis providedChecks for: Any files matching
"*_{year}.xml"
General check: When neither
namenoryearprovidedChecks for: Any
"*.xml"files in cache directory
On error (e.g., permission issues), the function:
Issues a warning with error details
Returns
FALSEto allow graceful error handling
See also
read_xml_cache()for reading cached datawrite_xml_cache()for writing data to cacheclear_cache()for removing cached files
Examples
if (FALSE) { # \dontrun{
# Check if any cache exists
if (cache_exists()) {
# Process cached data
}
# Check specific department cache
if (cache_exists(name = "CS")) {
cached_data <- read_xml_cache("CS")
}
# Check specific year
if (cache_exists(year = "20232024")) {
# Process cached data for year
}
# Check specific department and year
if (cache_exists(name = "CS", year = "20232024")) {
cached_data <- read_xml_cache("CS", "20232024")
}
} # }