log = Logger::getLogger(__CLASS__); if(class_exists("Predis\Client")){ try { $this->cache = new Predis\Client(array( "scheme" => $redis_scheme, "host" => $redis_host, "port" => $redis_port, "read_write_timeout" => 0)); $this->log->info("redis host: ".$redis_host); $this->log->info("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("*"); for($x=0;$xcache->hget($keys[$x], 'persistent'); if($pers=='true'||$pers=='1') { if(($query = $this->cache->hget($keys[$x], 'query'))!=null) { $this->log->info("going to recalculate the results for key: ".$keys[$x]); $fetchMode = $this->cache->hget($keys[$x], 'fetchMode'); $results = $database->doQueryNoCache($query, $fetchMode); $this->cache->hset($keys[$x], 'results', json_encode($results)); } } else { $this->log->info("going to delete the key: ".$keys[$x]); $this->cache->del($keys[$x]); } } $database->doDisconnect(); } else { $this->log->info("cache does not exist"); } } } $rc = new RefreshCache(); $rc->refresh(); ?>