Skip to contents

Removes cached XML files from the cache directory. Can selectively clear files for a specific department, academic year, or combination of both. If no filters are specified, clears all cached XML files.

Usage

clear_cache(name = NULL, year = NULL, cache_dir = NULL)

Arguments

name

Character string. Optional department code (e.g., "CS") to clear specific department cache files.

year

Character string. Optional academic year in YYYYYYYY format (e.g., "20232024") to clear cache files for a specific year.

cache_dir

Character string. Optional path to the cache directory. If NULL, uses the default cache location.

Value

Invisibly returns TRUE if the operation was successful. Throws an error if the operation fails.

Details

The function supports three clearing modes based on parameter combinations:

  1. Department-specific: When name is provided

    • Clears: "{name}.xml" or "{name}_{year}.xml" if year provided

  2. Year-specific: When only year is provided

    • Clears: All files matching "*_{year}.xml"

  3. Complete clear: When neither name nor year provided

    • Clears: All "*.xml" files in cache directory

The function will:

  • Initialize/verify the cache directory

  • Determine which files to remove based on parameters

  • Remove matching files

  • Display success message with number of files removed

Error Handling

If files cannot be deleted or the cache directory cannot be accessed. The error will include the specific error message and cache directory path.

See also

Examples

if (FALSE) { # \dontrun{
# Clear all cache files
clear_cache()

# Clear specific department's cache
clear_cache(name = "CS")

# Clear all departments for specific year
clear_cache(year = "20232024")

# Clear specific department and year
clear_cache(name = "CS", year = "20232024")

# Clear cache from custom location
clear_cache(cache_dir = "~/my_course_cache")
} # }