FilecacheTiered

Filepath: phork/php/cache/filecache/FilecacheTiered.class.php

The FilecacheTiered class is a caching adaptor that uses one of the FileSystem classes to write the cache to a file.

The cached files contain a serialized array with an expiration timestamp (Expire) and the cache content (Data). When a cache is read the expiration time is checked to make sure that the cache hasn't expired. If it has expired the cache file is removed.

In addition to standard caching functionality this adds the ability to cache data in namespaces. This allows you to easily flush a single namespace without having to flush the entire cache.

The flush() method has been disabled in the filecache to prevent an accidental recursive deletion of something that shouldn't be deleted.

The cache configuration file defines the type of file system to use, the root path relative to the filesystem's folder root (as defined in the global configuration file), and the number of levels deep to create a hash path.


Configuration Example

//the cache type must have a corresponding class
$arrConfig['Type'] = 'Filecache';


//the cache filesystem for the base tier; the base path is relative to the files dir
$arrConfig['Tiers']['Base'] = array(
    'FileSystem' => 'Local',
    'RootPath' => 'app/cache/base/',
    'HashLevel' => 10
);


//the cache filesystem for the presentation tier; the base path is relative to the files dir
$arrConfig['Tiers']['Presentation'] = array(
    'FileSystem' => 'Local',
    'RootPath' => 'app/cache/presentation/',
    'HashLevel' => 10
);