wwUtils::CacheFile

This method works like FILETOSTR() or FILE2VAR() to return the content of a file. The first time the file is read it's read from disk and then cached in a cursor. Subsequent requests for the same file (based on path + filename) retrieve the file from the cursor rather than from disk.

You can optionally check the file's timestamp to make sure that the file on disk hasn't changed.

Use this function instead of FILETOSTR() or FILE2VAR() in high volume scenarios where disk overhead becomes part of load issues on a Web site. Caching files in a cursor is 4 times faster than reading them from disk and saves considerable disk I/O overhead.

CacheFile(lcFileName,lnRefreshSeconds)

Return Value

File content as a string or ""

Parameters

lcFileName
The name of the file to read from disk and cache.

lnrefreshSeconds
Optional - forces files to be refreshed from disk after this amount of seconds has elapsed. Use this to get caching benefits while still keeping the ability to make changes to the files cached and update them after the timeout. A value of 0 specifies full caching and no refresh. Default: 0


See also:

Library wwUtils

© West Wind Technologies, 1996-2018 • Updated: 07/14/02
Comment or report problem with topic