log = Logger::getLogger("cleanCache"); 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 cleanUp() { $keys = $this->cache->keys("*"); for($x=0;$xcache->hget($keys[$x],'persistent'); //$this->log->info("id : ".$keys[$x]); //$this->log->info("persistent : ".$pers); if($pers=="false"||($pers=='0')) { $this->log->info("removing id : ".$keys[$x]); $this->cache->del($keys[$x]); } } 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 cleaning Cache Up! "); } } //$rc = new cleanCache(); //$rc->cleanUp(); ?>