-->*/ //log = Logger::getLogger(__CLASS__); Logger::configure('./js/log4php/log4php.xml'); $this->log->info("Calling scripts to modify Cache...."); $this->log->info("Script Mode:".$action); if(!$action=='help'){ echo ("Performing Action : ".$action."

"); } if ($action=='refreshNums') {$this->refreshNums();} else if ($action=='refreshCharts') {$this->refreshCharts();} else if ($action=='refreshAll') { $this->refreshAll(); } else if ($action=='promoteNums') {$this->promoteNums();} else if ($action=='promoteCharts') {$this->promoteCharts();} else if ($action=='promoteAll') { $this->promoteAll(); } else if ($action=='restore') { $this->restore(); } else if ($action=='backup') { $this->backup(); } else if ($action=='migrate') {$this->migrate($args);} else if ($action=='cleanUp') {$this->cleanUp();} else if ($action=='help') {$this->printHelp();} else {$this->log->info("Wrong argument given"); $this->printHelp();} if($action!=='help'){ echo("
Action Finished!
"); } } private function printHelp() { $msg="

Cache Controls

Availiable options for refresh :

refreshNums -> Refresh Stats Numbers Only
refreshCharts -> Refresh Chart Queries
refreshAll -> Refresh every entry in the cache.

Availiable options for promote :

promoteNums -> Promotes Stats Numbers Only;
promoteCharts -> Promote Chart Queries ;
promoteAll ->Promote every entry in the cache.

Availiable options for backup :

backup
restore
migrate
"; $this->log->info($msg); echo($msg); } public function refreshNums(){ $this->log->info("Refreshing Numbers..."); $csn = new ComputeStatsNumbers(); $csn->computeStats(); $this->log->info("Done!"); } public function refreshCharts() { $this->log->info("Refreshing Charts..."); $csn = new RefreshCharts();$csn->refresh(); $this->log->info("Done!"); } public function refreshAll() { $this->refreshNums(); $this->log->info("Refreshing Charts..."); $csn = new RefreshCharts();$csn->refresh(); $this->log->info("Done!");} public function promoteNums(){ $this->log->info(" Promoting Numbers..."); $csn = new PromoteShadowNums(); $csn->replace(); $this->log->info("Done!"); } public function promoteCharts() { $this->log->info("Promoting Charts..."); $csn = new PromoteCharts();$csn->replace(); $this->log->info("Done!"); } public function cleanUp() { $this->log->info("Cleaning Up Cache..."); $csn = new cleanCache(); $csn->cleanUp(); $this->log->info("Done!"); } public function migrate ($args) { //$this->log->info("Cache Migration not yet implemented"); $this->log->info("*************Migrating Cache to ".$args[0]." on ".$args[1]); $csn = new MigrateCache(); global $redis_remote_host; global $redis_remote_port; global $redis_remote_beta_host ; global $redis_remote_beta_port; if($args[0]=='production') { $csn->migrate($redis_remote_host,$redis_remote_port);} else if($args[0]=='beta' ) { $csn->migrate($redis_remote_beta_host,$redis_remote_beta_port);} else{ $csn->migrate($args[0],$args[1]); $this->log->info("Done!"); //echo("Cache Migration not yet implemented
"); } } public function backup() { $this->log->info("Backing Up Cache..."); $csn = new BackupCache();$csn->backup(); $this->log->info("Done!"); } public function restore() { $this->log->info("Restoring Cache..."); $csn = new RestoreCache();$csn->restore(); $this->log->info("Done!"); } public function promoteAll() { $this->promoteNums(); $this->promoteCharts();} } if ($_GET) { $action = $_GET['action']; $args = array( "0"=> $_GET['targetCache'], "1"=> $_GET['port']); //$args = array( "0"=> $_GET['targetCache']); } else {$action = $argv[1]; if(count($argv)>1) {$args = array("0"=> $argv[2], "1"=> $argv[3]);}} $rc = new CacheController($action,$args); /* */ ?>