PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of chema garrido  >  Wrapper Cache  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: Wrapper Cache
Wrapper to access several types of cache storages
Author: By
Last change:
Date: 11 years ago
Size: 1,544 bytes


Class file image Download
ini_set("display_errors", 1);

//optional code in
include 'fileCache.php';
//file wrapper cache example
include 'wrapperCache.php';

//creating new instance singleton
$cache = wrapperCache::GetInstance('filecache',36,'cache/');//all params are optional
//or set it in auto and the class will choose the cache engine for you ;)
//$cache = wrapperCache::GetInstance('auto');

//caching values
$cache->thevar='I\'m the bar from wrapper cache using filecache';//overload of set and get methods
$cache->cache('thevar','test values for the var!!!!');

//retrieving value for a key
echo $cache->thevar;//get
echo $cache->cache('thevar');//get

//isset and unset are overloaded

//displays availables cache engines in your system:
echo $cache->getAvailableCache();

//flush all cache

//example to add multiple servers of memcache
/*$memcache_servers =
        array (

$cache = wrapperCache::GetInstance('memcache',30, $memcache_servers );//creating new instance singleton*/

//or simpler way:
$cache = wrapperCache::GetInstance('memcache',30,array(array('host'=>'localhost')));

if (
$cache->cache('site',strip_tags(file_get_contents("")),100);//time overload

//end wrapper cache example


For more information send a message to info at phpclasses dot org.