PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Rob Searles   Really Simple Content Cache   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Demo of the ReallySimpleContentCache class for the simplest usage
Class: Really Simple Content Cache
Cache content in files
Author: By
Last change:
Date: 17 years ago
Size: 1,568 bytes
 

Contents

Class file image Download
<?php
/**
 * ReallySimpleContentCache - demo file for simplest usage
 * As the name suggests, this is class is for really simple content caching
 *
 * Copyright 2007 Rob Searles
 * http://www.ibrow.com
 * Please give me credit if you use this. Thanks
 *
 * History:
 * I originally built this for caching XML which had been constructed
 * out of database calls. I had a Flash front end talking to PHP in the
 * backend, the PHP would then go and interrogate the database, construct
 * some more XML which it would return. There were many calls being made to
 * the database, so I decided to cache the final reply XML.
 *
 * It's not bullet proof, and doesn't have a great deal of functionality,
 * but it is a quick and dirty solution to a little scratch I had to itch
 * Play around with it, learn, improve and enjoy. I hope you find it useful
 *
 * copyright 2007 rob searles
 * Licenced under the GNU Lesser General Public License (Version 3)
 * http://www.gnu.org/licenses/lgpl.html
 */
require('ReallySimpleContentCache.php');
/**
 * Initiate ReallySimpleContentCache class
 */
$Cache = new ReallySimpleContentCache('test');
/**
 * Try to get any content from the Cache
 */
$content = $Cache->get();
/**
 * If no content has been given, go off and create some
 */
if(!$content) {
   
$content = '<html><body><h1>Hello</h1><p>This file was created on '.
       
date ('F d Y H:i:s.', time()).'</p></body></html>';
   
/**
     * now cache this content
     */
   
$Cache->save($content);
}
/**
 * output the content
 */
echo $content;
?>