log = Logger::getLogger("RestoreCache"); 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; } } public function restore() { //first restore numbers $backupKeys=$this->cache->hkeys('STATS_NUMBERS_BACKUP'); $this->log->info("Restoring Stat Numbers..."); for($x=0;$xcache->hget('STATS_NUMBERS_BACKUP',$key); $this->cache->hset('STATS_NUMBERS',$key,$value); } //now promote all other entries $keys = $this->cache->keys("*"); $this->log->info("Restoring data queries..."); $this->log->info("*******************************************"); for($x=0;$xcache->hget($keys[$x],'query'); $persistent= $this->cache->hget($keys[$x],'persistent'); if($query!=null) { $fetchMode = $this->cache->hget($keys[$x], 'fetchMode'); $shadowResults = $this->cache->hget($keys[$x],'shadow'); $result = $this->cache->hget($keys[$x], 'results'); $backup = $this->cache->hget($keys[$x], 'backup'); $this->cache->hmset($keys[$x],array("results" =>$backup,"query" =>$query,"persistent" =>$persistent,"shadow" =>$shadowResults,"fetchMode" =>$fetchMode,"backup" =>$backup)); $this->log->info("Restored ".$keys[$x]); } }//catch catch(Exception $e) { $this->log->error('Error : '.$e->getMessage()); } } else { $this->log->info("Ignoring chart key: ".$keys[$x]); } } $this->cache->quit(); $this->log->info("Done! "); } } ?>