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 refresh() { if($this->cache != null){ $this->log->info("cache exists"); $database = new MYDB(); $database->doConnect($GLOBALS['schema_file']); $keys = $this->cache->keys("*"); $this->log->info(" ******************REFRESHING CACHE*************************"); //TODO REFRESH CHARTS AND DATA for($x=0;$xlog->info("Looking up for key: ".$keys[$x]); if (strpos($keys[$x],'STATS')===false) { try { $query = $this->cache->hget($keys[$x],'query'); $persistent= $this->cache->hget($keys[$x],'persistent'); //if($query!=null&&$persistent=='true') if($query!=null) { $this->log->info("going to recalculate the results for query ".$query ); $fetchMode = $this->cache->hget($keys[$x], 'fetchMode'); if($fetchMode==null) { $fetchMode=3; } $shadowResults = $database->doQueryNoCache($query, $fetchMode); $result = $this->cache->hget($keys[$x], 'results'); // $this->log->info("Currently stored results".$result ); $backup = $this->cache->hget($keys[$x], 'backup'); //$this->log->info("Currently stored backup".$backup); if(json_encode($shadowResults)) {$shadowResults=json_encode($shadowResults);} $this->cache->hmset($keys[$x],array("results" => $result, "query" =>$query,"persistent" => $persistent,"shadow" => $shadowResults, "fetchMode" => $fetchMode, "backup" => $backup)); $this->log->info("Stored Entry : ".$this->cache->hget($keys[$x],'shadow')); } else{ $this->log->info("going to delete the key: ".$keys[$x]." for persistence : ".$persistent); $this->cache->del($keys[$x]); } }//catch catch(Exception $e) { $this->log->error('Error : '.$e->getMessage()); } } else { $this->log->info("Ignoring chart key: ".$keys[$x]); } } // for eeach key loop $database->doDisconnect(); } else { $this->log->info("cache does not exist"); } } } //$rc = new RefreshCharts(); //$rc->refresh(); ?>