log = Logger::getLogger(__CLASS__); Logger::configure('./js/log4php/log4php.xml'); if(class_exists("Predis\Client")){ try { //todo changed timeout from 0 to -1 $this->cache = new Predis\Client(array("scheme" => $redis_scheme,"host" => $redis_host,"port" => $redis_port,"read_write_timeout" => -1)); $this->log->info("redis host: ".$redis_host." and redis port: ".$redis_port); } catch(Exception $e) { $this->log->error("Error connecting to Redis server: ".$e->getMessage()); $this->cache = null; } } else{ $this->log->info("cache does not exist"); //predis exit; } } function backup() { if($this->cache != null){ $this->log->info("cache exists"); $database = new MYDB(); $database->doConnect($GLOBALS['schema_file']); $keys = $this->cache->keys("*"); $this->log->info(" *******************BACKING UP NUMS************************"); $numKeys=$this->cache->hkeys('STATS_NUMBERS'); for($x=0;$xcache->hget('STATS_NUMBERS',$key); $this->cache->hset('STATS_NUMBERS_BACKUP',$key,$value); } $this->log->info("All Num Entries Backed up Sucessfully!"); //NOW PROCEED TO CHARTS AND DATA for($x=0;$xcache->hget($keys[$x],'query'); $persistent= $this->cache->hget($keys[$x],'persistent'); if($query!=null) { $this->log->info("going tobackup the results for query ".$query ); $fetchMode = $this->cache->hget($keys[$x], 'fetchMode'); if($fetchMode==null){ $fetchMode=3; } $shadowResults =$this->cache->hget($keys[$x],'shadow'); $result = $this->cache->hget($keys[$x], 'results'); $this->cache->hmset($keys[$x],array("results" => $result, "query" =>$query,"persistent" => $persistent,"shadow" => $shadowResults, "fetchMode" => $fetchMode, "backup" => $result)); $this->log->info("Stored Entry : "); $this->log->info("backup ".$this->cache->hget($keys[$x],'backup')); } }catch(Exception $e) { $this->log->error('Error : '.$e->getMessage()); } } else {$this->log->info("Ignoring chart key: ".$keys[$x]); } } $database->doDisconnect(); $this->log->info("Finished Backup! : "); } } } ?>