PHP Classes

Cache Manager: Manage cache containers to store and retrieve data

Recommend this page to a friend!
  Info   View files View files (15)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-12-03 (20 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: 290 This week: 1All time: 7,480 This week: 256Up
Version License PHP version Categories
cache-manager 2.11BSD License5.3.0PHP 5, Cache
Description 

Author

This package can manage cache containers to store and retrieve data.

The factory class can create an object of one of several class container classes given the name of the type of cache storage.

The cache container object can store data in a cache container for a given time during which the cache is valid.

It can also retrieve the cached data if it is still valid.

Currently it provides cache container classes for storing data in files or APC.

Picture of Camilo Sperberg
  Performance   Level  
Name: Camilo Sperberg <contact>
Classes: 8 packages by
Country: The Netherlands The Netherlands
Age: 41
All time rank: 75720 in The Netherlands The Netherlands
Week rank: 73 Up1 in The Netherlands The Netherlands Up

Details

cacheManager.class.php ====== Credits -------- This class is made by unreal4u (Camilo Sperberg). [http://unreal4u.com/](unreal4u.com) About this class -------- * Can be used to cache different things. * Anything you choose, it will cache: strings, objects, boolean, etc. * Change quickly from one type of cache to another (Included: file and APC). * Posibility to write your own wrappers! * With APC cache, you can delete a part of the cache, all of it or just one entry very easily. Detailed description --------- This package will use the cache engine of your choice to save things to cache. There are many other very good engines out there (ZendCache / fluxBB-cache) that are probably better but this one is made with speed, ease of use and stability in mind. It will also give you the capability to write your very own cache mechanism and implement it very quickly as all calls are identical. Besides, it was a nice exercise to learn something about reflection and some other stuff, but therefore **this class will need PHP 5.3.0 as minimum**. This package has been extensivily tested with xdebug, APC and Suhosin so that no errors are present. Basic usage ---------- <pre>include('cacheManager.class.php'); try { $cache = new cacheManagerClass('apc'); } catch (cacheException $e) { print('Exception caught! Message: "'.$e->getMessage().'"'); } catch (versionException $e) { die($e->getMessage()); } $secondExample = $cache->load('secondExample', array('en_US')); if (empty($secondExample)) { // If empty, it means we don't have that cache yet or it is too old, create it $secondExample = 'Some very long process that would be useful to cache'; // Save for 120 seconds $cache->save($secondExample, 'secondExample', null, 120); }</pre> * Congratulations! Everything is now properly saved in cache! Sit back and watch your server going nuts serving requests. * Please see examples for more options and advanced usage Pending --------- * Support for memcache Version History ---------- * 1.1: * Tested on production * 2.0: * It is now possible to make your own wrappers * Documentation improved (Created this README actually) * File-based cache * Exception enhancing * First release to public * 2.1: * Bug fixes * Better separation * 2.2: * Type hinting where possible * There is now a toggle debug mode function. When debug mode is enabled, it means that no calls are actually made to the cache functions, making this class rather useless, but very useful for debugging. * 2.3: * Default base class which can be implementable if APC (or another of your choice) doesn't work. This way your code won't fail because at least the object and base methods will be defined * 2.5: * Added support for redis Contact the author ------- * Twitter: [@unreal4u](http://twitter.com/unreal4u) * Website: [http://unreal4u.com/](http://unreal4u.com/) * Github: [http://www.github.com/unreal4u](http://www.github.com/unreal4u)

  Files folder image Files  
File Role Description
Files folder imagecacheTypes (4 files)
Files folder imagedocumentation (5 files)
Files folder imagetests (2 files)
Accessible without login Plain text file cacheManager.class.php Class Class itself
Accessible without login Plain text file cacheManager.interface.php Class Auxiliary needed class
Accessible without login Plain text file exceptions.class.php Class Auxiliary needed class
Accessible without login Plain text file README.md Data Auxiliary data

  Files folder image Files  /  cacheTypes  
File Role Description
  Accessible without login Plain text file apcCache.class.php Class Auxiliary needed class
  Accessible without login Plain text file defaultCache.class.php Class Auxiliary needed class
  Accessible without login Plain text file fileCache.class.php Class Auxiliary needed class
  Accessible without login Plain text file redisCache.class.php Aux. Auxiliary script

  Files folder image Files  /  documentation  
File Role Description
  Accessible without login Plain text file create-cache-apc.php Example Example script
  Accessible without login Plain text file create-cache-file.php Example Example script
  Accessible without login Plain text file fallback-apc.php Example Example script
  Accessible without login Plain text file purge-cache-apc.php Example Example script
  Accessible without login Plain text file purge-cache-file.php Example Example script

  Files folder image Files  /  tests  
File Role Description
  Accessible without login Plain text file cacheManagerAPCTest.php Test Unit test script
  Accessible without login Plain text file phpunit.xml Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:290
This week:1
All time:7,480
This week:256Up