RFKcache 1.0.1 - A PHP caching engine


    include( "class.rfkcache.php" );

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

    // ... 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 );


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


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 --

    $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()) {

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()) {
        echo $pagcache->Cache_Fetch();

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 )) {

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.


Cache_OutputHTML( )

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


Cache_Delete( )

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



You're reading it.


Revision 1.0.1 - Aug 11, 2002 © RFK Solutions <>


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

1.0.0 Initial public release


CopyRight (c) 2002 RFK Solutions, 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,

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


FastTemplate PHP3 module, available from CDI -

RFKmap module, available in