PHP Classes
elePHPant
Icontem

File: test.php

Recommend this page to a friend!
  Classes of Abdulrahman Muhammad  >  Ocache  >  test.php  >  Download  
File: test.php
Role: Example script
Content type: text/plain
Description: sample
Class: Ocache
Cache variable values in files or APC
Author: By
Last change:
Date: 3 years ago
Size: 764 bytes
 

Contents

Class file image Download
<?php
/*
 * test file for ocache class
 *
 */

#get the class
include 'ocache.php';

#initiate it
$cache = new ocache('cache');

#or
# $cache = new ocache('cacheFolder', 'apc');
#or
# after initiate the class you can specify the cache folder and type of caching
#
# type of caching can be files or depending on APC:
#
# $cache->dir_path = 'whatever';
# $cache->type = 'APC';

if(($cached_data = $cache->get('stuff_names')) === false){
   
#echo 'test:1';
    #here you can get stuff from mysql database and .. save it to cache
   
$cached_data = array('name1' => 'Abdul', 'name2'=>'Muhammad', 'name3'=>'Osama');
   
   
#save it, using default type of caching or APC
   
$cache->save('stuff_names', $cached_data, 3600); # 3600 is seconds
}

#NOW use it
print_r($cached_data);