Nen Cache - File cache class

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Nen Cache - File cache class

    This class can be used to cache the output of PHP generated pages in files.

    It can capture the output of a PHP script section and cache it by storing the output in files.

    The output data is cached for a given timeout period. While the cache does not expire, the data is retrieved from the cache file.

    The cache file path and the timeout period are configurable.
    Usage : view example.php

    Simple usage :
    PHP Code:
    <?php
    include "nen.class.php";



    $path 'cache/'// We set cache path ! Do not forget '/'
    $cache_adv = new nencache;
    $cache_name='page1'// 
    $cache_time '3600'// (3600s = 1h :D )
    if ($cache_adv -> start ($cache_name,$cache_time,$path)) {

    ///my normal page content here 
    $cache_adv -> build ($path);
    }
    ?>
    I use this class to cache results from mysql query .
    DO not include dinamic ads (e.g. from admob) in this code , because will be cached ..and is not good

    An way to add dinamic ads in cached files can be the usage of some text e.g. [top_admob_ad]
    and on output replace this with admob function :-?


    If you have a better (or not) cache class , please post here .
    Attached Files
    Unamos los corazones,hoy todos somos multicolores!

    #2
    hw can i specify not cache this content

    Comment


      #3
      PHP Code:
      ///content here will not be cached


      if ($cache_adv -> start ($cache_name,$cache_time,$path)) {

      ///my normal page content here
      /// all content from here will be cached 
      $cache_adv -> build ($path);
      }

      ///content here will not be cached 
      Unamos los corazones,hoy todos somos multicolores!

      Comment


        #4
        Nice code
        I hope i can implement it into my forum, but one hour seems to be to much for a dynamic site, 5 mins would be a better choice

        Comment


          #5
          Just delete the cache file when you add something new.
          <?php unlink('World/Europe/Romania.country'); ?>

          Comment


            #6
            u cn use memcache also

            Comment

            Working...
            X