PHP Classes

Cache Master: Store and retrieve data in cache files

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 453 All time: 6,156 This week: 560Up
Version License PHP version Categories
cache-master 3Freely Distributable5Cache
Description 

Author

This class can store and retrieve data in cache files.

The class can store given data with a given key in cache file under a given cache directory. The cache directory is created if it does not exist.

The class stores the cache data in a file and the cache metadata in another file that holds the cache expiry time.

The class can also check if the cache file exists and retrieve the stored data, check if the cache file expired, or remove existing cache files.

Picture of Anthony Amolochitis
  Performance   Level  
Name: Anthony Amolochitis <contact>
Classes: 10 packages by
Country: United States United States
Age: 44
All time rank: 1138166 in United States United States
Week rank: 214 Up28 in United States United States Up

Recommendations

What is the best PHP page caching class?
Need best caching to store XML documents

Example


$someData = new stdClass();
$someData->oneItem = 'One Item';
$someData->twoItem = 'Two Item';
$someData->threeItem = 'Three Item';

$jsonEncodedData = json_encode($someData);
$key = 'SomeUniqueId';
$customDirectory = '/tmp/customDirectory/';


/*
 * Cache it
 */
$CachedMaster = new CacheMaster();
$CachedMaster->setCacheDir($customDirectory);
$CachedMaster->put($key, $jsonEncodedData);


/*
 * Load it
 */
if( $CacheMaster->exists($key) )
{
    $x = json_decode( $CacheMaster->get($key), true);
    echo '<pre>';
    print_r($x);
    echo '</pre>';
}


  Files folder image Files (2)  
File Role Description
Plain text file CacheMaster.php Class Simple Cache Utility
Plain text file Example.php Example Example Usage

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:453
This week:0
All time:6,156
This week:560Up