Project

General

Profile

1
<?php
2
require_once('./js/log4php/Logger.php');
3
require_once('./paths.php');
4
require_once('./MYDB.php');
5

    
6
class test {
7
	private $log;
8
	private $cache = null; //predis
9

    
10
public function __construct(){
11
		
12
		global $redis_host;
13
		global $redis_port;
14
		global $redis_scheme;
15
		global $host;  
16
               
17

    
18
               $this->log = Logger::getLogger("cleanCache");
19
               Logger::configure('./js/log4php/log4php.xml');	
20
 
21
             if(class_exists("Predis\Client")){
22

    
23
                        try {
24
//todo changed timeout from 0 to -1 
25
                        $this->cache = new Predis\Client(array("scheme" => $redis_scheme,"host" => $redis_host,"port" => $redis_port,"read_write_timeout" => -1));
26
                                $this->log->info("redis host: ".$redis_host." and redis port: ".$redis_port);
27
                        } catch(Exception $e) {
28
                                $this->log->error("Error connecting to Redis server: ".$e->getMessage());
29
                                $this->cache = null;
30
                        }
31
                }
32
        else{
33
            $this->log->info("cache does not exist"); //predis
34
                        exit;
35
        }
36

    
37

    
38
	}
39
public function testUp()
40
{
41
 
42
$keys = $this->cache->keys("*");
43

    
44
for($x=0;$x<count($keys);$x++) {
45
if (strpos($keys[$x],'STATS')===false)
46
{
47
try
48
{
49
$pers=$this->cache->hget($keys[$x],'persistent');
50
//$this->log->info("id : ".$keys[$x]);
51
//$this->log->info("persistent : ".$pers);
52

    
53

    
54
if($this->cache->hget($keys[$x],'results')=='')
55
{
56
$this->log->info("empty result id : ".$keys[$x]);
57
}
58

    
59
if($pers=="false"||($pers=='0'))
60
{
61
$this->log->info("non persistent id : ".$keys[$x]);
62

    
63

    
64

    
65
//$this->cache->del($keys[$x]);
66

    
67
}
68
}
69
catch(Exception $e) 
70
{$this->log->error('Error : '.$e->getMessage());}
71

    
72
}
73
else
74
{ $this->log->info("Ignoring chart key: ".$keys[$x]); }
75

    
76
}
77
$this->cache->quit();
78
$this->log->info("Done cleaning Cache Up! ");
79

    
80
}
81

    
82
}
83
$rc = new test();
84
$rc->testUp();
85
?>
(9-9/30)