Login   Register  
PHP Classes
elePHPant
Icontem

File: usage.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Shaun Thomas  >  cache  >  usage.txt  >  Download  
File: usage.txt
Role: ???
Content type: text/plain
Description: How to Use The Classes
Class: cache
Author: By
Last change:
Date: 2001-06-07 22:05
Size: 950 bytes
 

Contents

Class file image Download
<?PHP

//  Here is an example on how to use the buffer/cache class
//  combination I've created.

// Create an output buffer
$BUFF = new CBuffer;

// Create a cache object.
$tmpDir = "/tmp/cache/";
if (!is_dir($tmpDir))
  mkdir($tmpDir, 0755);
$CACHE = new CCache($tmpDir);

// Cache should expire in an hour.
$CACHE->expire = 3600;

// If the file is cached, just print it.  Otherwise, go on with the
// rest of the program.
if ($cached = $CACHE->retrieve())
{
  print $cached;
  exit();
}

/*

  This is where your page will operate.  Notice that
  you can easily use the cache in a header/footer
  combination, perhaps through auto_prepend_file/
  auto_append_file or maybe a couple of functions.

*/

// Get the latest contents of the output buffer.
$BUFF->freshen();

// Print the buffer.
$BUFF->stop();
$BUFF->dump();

// Finally, cache the output we've calculated.
$CACHE->save($BUFF->buff);

?>