NAME

O::CacheDir - Perl module to aid in keeping track and cleaning up files, quickly and without a cron $Id: CacheDir.pod,v 1.1 2001/04/03 21:41:32 earl Exp $

SYNOPSIS

CacheDir takes up to three parameters and returns a fully qualified filename. Cool part is that it quickly and automatically cleans up files that are too old.

The possible named arguments (which must be named, see below for an example) are,

filename - which is what you want the file without the directory to be named, like "storebuilder" . time . $$ I would suggest using a script specific word (like the name of the cgi), time and $$ (which is the pid number) in the filename, just so files are easy to track and the filenames are pretty unique

ttl - how long you want the file to stick around can be given in seconds (3600) or like "1 hour" or "1 day" or even "1 week"

base_dir - the base directory use $ROOTDIR_LOG for something that is just on one box, and use $ROOTDIR_TMPCOMMON for something that needs to be shared (like between web boxes)

EXAMPLE

#!/usr/bin/perl -w

use strict;
use O::Is qw(is);
use O::CacheDir qw(cache_dir);
use O::magics qw($ROOTDIR_TMPCOMMON);

my $file = cache_dir(base_dir => $ROOTDIR_TMPCOMMON, ttl => '3 hours');

is $file;
`touch $file`;