NAME

RFKcache 1.0.1 - A PHP caching engine


SYNOPSIS

    include( "class.rfkcache.php" );

    $pagcache = new Cache( "mainpage", "cache/");
    if (!$pagcache->Cache_Eval_Yesterday()) {
        $pagcache->Cache_Read();
        $pagcache->Cache_OutputHTML();
        exit;
    }

    // ... example 1:
    $contents = "";
    $contents.= "My personal page";
    $contents.= "Caching in ". date("m-d-Y");

    // ... example 2:
    include "class.FastTemplate.php3";
    $tpl = new FastTemplate( "templates/" );
    $tpl->define( array( "main" => "main_page.tpl") );
    ...
    $tpl->parse( CONTENTS, "main" );
    $contents = $tpl->fetch("CONTENTS") );

    // ...

    $pagcache->Cache_Write( $contents );


DESCRIPTION

RFKcache is a easy, efficient and simple class which implements a cache system for use in PHP3/4 programs.


METHODS


new( unique_identifier, [cache_path] )

This is a constructor's class method. Requires an unique_identifier to identify cache blocks of code in a cache-directory cache_path.

    $pagcache = new Cache( "mainpage", "cache/");

-- Example: dynamic pages --
    URL: www.somewhere.com/list.php?section=2&language=en
    URL: www.somewhere.com/list.php?section=5&language=en

    $pagcache = new Cache( "listsection_".$section."_".$language, "cache");


Cache_Read( )

The function Cache_Read() reads the stored data from cached-file.

    if (!$pagcache->Cache_Eval_Yesterday()) {
        $pagcache->Cache_Read();
        $pagcache->Cache_Output();
        exit;
    }


Cache_Write( $content )

The function Cache_Write() writes the content of variable $content in a cached-file. This is the primary function to storage all cached data.

    $pagcache->Cache_Write( $contents );

Cache_Eval_Yesterday( )

The funcion Cache_Eval_Yesterday() checks if a new data must been stored from yesterday.

    if (!$pagcache->Cache_Eval_Yesterday()) {
        $pagcache->Cache_Read();
        echo $pagcache->Cache_Fetch();
        exit;
    }


Cache_Eval_ExpireIf( expression )

The funcion Cache_Eval_ExpireIf() checks if a new data must been stored from time-expression.

    if (!$pagcache->Cache_Eval_ExpireIf( /*cachetime: 1 hour*/ 3600 )) {
        $pagcache->Cache_Read();
        $pagcache->Cache_OutputHTML();
        exit;
    }


Cache_Fetch( )

The method Cache_Fetch() returns the raw data from a cached script.

    $rawdata = $pagcache->Cache_Fetch();

    fwrite($fd, $rawdata);   // save to a file
    echo $rawdata            // print


Cache_Output( )

The method Cache_Output() prints the raw data stored in cached-file from executed script.

    $pagcache->Cache_Output();


Cache_OutputHTML( )

The method Cache_OutputHTML() prints the contents of cached script from file stored in HTML format.

    $pagcache->Cache_OutputHTML();


Cache_Delete( )

The method Cache_Delete() deletes the cached-file that store data cached.

    $pagcache->Cache_Delete();


DOCUMENTATION

You're reading it.


VERSION

Revision 1.0.1 - Aug 11, 2002 © RFK Solutions <rfksolutions@users.sourceforge.net>


HISTORY

1.0.1 Added Cache_Delete() and Cache_Eval_ExpireIf(). Version released Aug 11, 2002.

1.0.0 Initial public release


AUTHOR

CopyRight (c) 2002 RFK Solutions, rfksolutions@users.sourceforge.net. All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the GNU General Artistic License, with the following stipulations;

Changes or modifications must retain these Copyright statements. Changes or modifications must be submitted to the author.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Artistic License for more details. This software is distributed AS-IS.

Address Bug Reports or Comments to RFK Solutions, rfksolutions@users.sourceforge.net.

The latest version of this class should be available from the following locations:

http://rfkmap.sourceforge.net


SEE ALSO

FastTemplate PHP3 module, available from CDI - http://www.thewebmasters.net

RFKmap module, available in http://www.hotscripts.com/Detailed/11382.html