Approach For Cache System: Step 1: Create A Table To Save Last Bug Fix Update Time
Approach For Cache System: Step 1: Create A Table To Save Last Bug Fix Update Time
Approach For Cache System: Step 1: Create A Table To Save Last Bug Fix Update Time
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `0210_01`
--
-- --------------------------------------------------------
--
-- Table structure for table `app_bug_fix`
--
--
-- Dumping data for table `app_bug_fix`
--
DELIMITER $$
DROP PROCEDURE IF EXISTS `sp_selectAppBugFixes`$$
CREATE PROCEDURE `sp_selectAppBugFixes`(
_id BIGINT(20)
)
BEGIN
select
ads.id as id,
ads.last_fix_time as last_fix_time
from
app_bug_fix as ads
where
ads.id = _id
;
END$$
DELIMITER ;
-- End sp_selectAppBugFixes--------------
class AppBugFixes {
public $id;
public $last_fix_time;
private $db;
This class will basically contain only the load function as Save or Update function will take place when some change is pushed to production. That can be thinked of later.
Step 4. Make a folder bug_fixes in app/tab and make 2 subfolders in the same: 1 for config.ini and other for install.sql
according to this new class:
[development]
class = AppBugFixes
Step 5. Make a new folder cache in project root and add a new file Cache.php. This will be the base class for caching
implementation:
class Cache{
// location and prefix for cache files
//const CACHE_PATH = "/wamp/www/time/cache/cache_";
//define('CACHE_PATH','/wamp/www/time/cache/cache_');
var $_cache_path;
var $_cache_time;
var $_fanpageid;
$file = $this->cache_file();
// check that cache file exists and is not too old
if(!file_exists($file)) return;
if(filemtime($file) < time() - $this->_cache_time * 3600) return;
// if so, display cache file and stop processing
readfile($file);
exit;
}
}
Step 7. Add support for Bug Fix class in FaceBookApp.
$deal_share = $fb_app->getBusinessInstance();
$bug_fix = $fb_app_bugfix->getBusinessInstance();
$deal_share->pages_id = $page_id;
$bug_fix->id = $id;
$parameters = $deal_share->load();
$parameters_bugfix = $bug_fix->load();
$file = $obj->cache_file();
$array = $obj->cache_load();
$QueryString = '';
$first = true;
foreach ($parameters as $Key => $Value){
if(!$first){
$QueryString .= "<br/>".$Key.'='.$Value ;
}else{
$QueryString .= $Key.'='.$Value ;
$first = false;
}
}
$obj->cache_page($QueryString);
}elseif($parameters['last_update_time'] < $parameters_bugfix['last_fix_time']){ // check that cache file is older then last bug fix update
unlink($file);
$file = $obj->cache_file();
$obj->cache_page($QueryString);
$array = $obj->cache_load();
}else{
print_r($array);