PEAR Articles

  Home arrow PEAR Articles arrow Page 5 - Caching with PEAR::Cache
PEAR ARTICLES

Caching with PEAR::Cache
By: bluephoenix
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2004-03-19

    Table of Contents:
  • Caching with PEAR::Cache
  • Installing Pear::Cache
  • Defining the Cache
  • Implementing a Framework
  • Combined Code
  • Conclusion

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Caching with PEAR::Cache - Combined Code


    (Page 5 of 6 )

    Based on the points illustrated in this tutorial, a possible framework for a cached script could resemble the following:

    <?php
    include "Cache.php";

    $store_as "file";
    $options = array("cache_dir" =&gtgetcwd() . "/cache");

    $cache = new cache($store_as$options);
    $cached_id $cache-&gt;generateID($_SERVER["PHP_SELF"]);

    if (
    $content $cache-&gt;get($cached_id))
      echo 
    $content;
    else {
      
    ob_start();
      
    // ...PHP script which results in output goes here.
      
    $content ob_get_contents();
      
    ob_end_clean();
      
    $cache-&gt;save($cached_id$content3600);
      echo 
    $contents;
    }
    ?>

    More PEAR Articles Articles
    More By bluephoenix

    blog comments powered by Disqus

    PEAR ARTICLES ARTICLES

    - Installing PEAR
    - PEAR: an Introduction
    - Managing robots.txt using PHP: Generating Dy...
    - Deleting Authors from a PEAR Content Managem...
    - PEAR CMS: Index and Delete Scripts
    - Listing Articles for a PEAR Content Manageme...
    - Building an Authors Page for a PEAR CMS
    - Building the View Details Page in a PEAR CMS
    - Creating the Main Pages of a PEAR CMS
    - Completing the Login Script for a PEAR CMS
    - User Authentication for a PEAR CMS
    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap