ADOdb Library for PHP Manual
Prev CacheFlush Next

CacheFlush($sql=false)

Flush (delete) any cached recordsets for the SQL statement $sql in $ADODB_CACHE_DIR.

If no parameter is passed in, then all adodb_*.cache files are deleted.

If you want to flush all cached recordsets manually, execute the following PHP code (works only under Unix):

    system
("rm -f `find ".$ADODB_CACHE_DIR." -name adodb_*.cache`");

CacheSelectLimit() rewrites the SQL query, so you won't be able to pass the SQL to CacheFlush. In this case, to flush the cached SQL recordset returned by CacheSelectLimit(), set $secs2cache to 0:

	$db->CacheSelectLimit(0, $sql, $nrows);

For general cleanup of all expired files, you should use crontab on Unix, or at.exe on Windows, and a shell script similar to the following:

#------------------------------------------------------
# TRUNCATING OUTPUT FILES OLDER THAN N DAYS
#
# Everything between the 3 lines above and their matching
# lines at the bottom of this section show you how to
# delete any log files whose modification time
# is older than AGED. The AGED variable can be coded in the
# script or passed on the command line.
#------------------------------------------------------
# This particular example deletes files in the TMPPATH
# directory with the string ".cache" in their name that
# are more than 7 days old.
#------------------------------------------------------
AGED=7
find ${TMPPATH} -mtime +$AGED | grep ".cache" | xargs rm -f


Prev Home Next
CacheSelectLimit Up Prepare

Sponsored by phpLens