fcache: List, clean or manipulate the file cache
Package: system
Usage
fcache cmd
Parameters
- cmd
- Cache command to execute. A description of each command is given below.
- pattern = "*"
- Filename substring pattern to match when initializing the cache with the init command.
- src = ""
- Source string used to generate the cache filename. This is typically the full path to a local file being cached or a URL.
- fname = ""
- Name of the file in the cache.
- extn = ""
- Cache filename extension.
- age = -1
- Age of the file (in days) to be purged with the purge command. A value less than zero means that the cache_age environment variable should is used to set the age, a value of zero means to delete all files in the cache (same as the init command), a value greater than zero means that files older than this age will be deleted.
- verbose = no
- Print status information as the task processes the command.
- wait = yes
- Block on operation? If 'yes' then the task will block until the requested file becomes available in the cache.
- cache = "cache$"
- Cache directory to be used.
Description
The FCACHE command is used to list or manage the system file cache named by the cache parameter. If the cache directory does not exist, it will be created when required. The cache_age environment variable determines the default maximum age of files in the cache, older files are automatically removed by the login.cl as part of the startup process.
The IRAF file cache is used primarily to cache local copies of URLs in the system to prevent repeated downloads when accessing URLs from tasks. This allows a URL to be passed to multiple tasks without explicitly requiring the user to create a named (temporary) file themselves.
The cmd parameter determines the action to take, other parameters are used as needed depending on the command according to the following table:
Command Input Pars Output Pars Action
------- ---------- ----------- ------
init pattern Initialize the cache
purge age Purge old files
destroy Destroy the cache
list List cache contents
lookup src fname,extn Lookup a file in the cache
access src Is file in cache?
add src extn fname Add file to the cache
delete src fname Delete file from cache
wait src Wait for access to file
The lookup command works in two ways: If a src string is provided then the fname parameter will contain the matching cached file (and extn will contain the optional extension), if the fanme parameter is specified then on output src will contain the original filename/URL.
Examples
1. Remove all "url" files from the cache.
cl> fcache init pattern="url"
2. List the contents of the file cache.
cl> fcache list
3. Destroy a cache directory (i.e. remove it entirely).
cl> fcache destroy cache="/tmp/cache"
4. Purge all cache files older than 7 days:
cl> fcache purge age=7
5. Determine if a URL is already in the cache:
cl> fcache add src="/tmp/dpix.fits"
cl> fcache list
f1128531670 1 /tmp/dpix.fits
f789045894 1 http://iraf.noao.edu/vao/dpix.fits
cl> fcache access src="/tmp/dpix.fits"
yes
cl> fcache access src="http://iraf.noao.edu/vao/dpix.fits"
yes
6. Delete a cached URL:
cl> fcache delete src="http://iraf.noao.edu/vao/dpix.fits"
7. Add a local file to the cache, then look it up:
cl> fcache add src="/tmp/test.fits"
cl> fcache lookup src="/tmp/test.fits"
cl> =fcache.fname
f1295587026
cl> fcache lookup fname="f1295587026"
cl> =fcache.src
/tmp/test.fits
Bugs
See also
head