PHP Classes

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


Class file image Download
 * test file for ocache class

#get the class
include 'ocache.php';

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

# $cache = new ocache('cacheFolder', 'apc');
# 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