1
|
<?php
|
2
|
require_once('./js/log4php/Logger.php');
|
3
|
require_once('./paths.php');
|
4
|
//require_once('./MYDB.php');
|
5
|
include_once('./MYDB.php');
|
6
|
//require_once('./controller.php');
|
7
|
|
8
|
class TestClean{
|
9
|
private $log;
|
10
|
private $cache = null;
|
11
|
public function __construct(){
|
12
|
|
13
|
$this->log = Logger::getLogger(__CLASS__);
|
14
|
Logger::configure('./js/log4php/log4php.xml');
|
15
|
|
16
|
if(class_exists("Predis\Client")){
|
17
|
|
18
|
try {
|
19
|
//todo changed timeout from 0 to -1
|
20
|
$this->cache = new Predis\Client(array("scheme" => "tcp","host" => "beta.stats.openaire.eu","port" => "6379","read_write_timeout" => -1));
|
21
|
// $this->log->info("redis host: ".$redis_host." and redis port: ".$redis_port);
|
22
|
} catch(Exception $e) {
|
23
|
$this->log->error("Error connecting to Redis server: ".$e->getMessage());
|
24
|
$this->cache = null;
|
25
|
}
|
26
|
}
|
27
|
else{
|
28
|
$this->log->info("cache does not exist"); //predis
|
29
|
exit;
|
30
|
}
|
31
|
}
|
32
|
|
33
|
|
34
|
function test() {
|
35
|
if($this->cache != null){
|
36
|
|
37
|
$keys = $this->cache->keys("*");
|
38
|
echo(" ******************TEST CACHE*************************");
|
39
|
|
40
|
//TODO REFRESH CHARTS AND DATA
|
41
|
|
42
|
$pertrue=0;
|
43
|
$perfalse=0;
|
44
|
$per1=0;
|
45
|
$datas=0;
|
46
|
|
47
|
echo(count($keys));
|
48
|
for($x=0;$x<count($keys);$x++)
|
49
|
{
|
50
|
if(strpos($keys[$x],'STATS')===false)
|
51
|
{
|
52
|
|
53
|
|
54
|
$query = $this->cache->hget($keys[$x],'query');
|
55
|
|
56
|
if($query!=null)
|
57
|
{
|
58
|
|
59
|
if($this->cache->hget($keys[$x],'persistent')=='true')
|
60
|
{
|
61
|
$pertrue++;
|
62
|
}
|
63
|
|
64
|
|
65
|
if($this->cache->hget($keys[$x],'persistent')=='false')
|
66
|
{$perfalse++;
|
67
|
|
68
|
$this->cache->del($keys[$x]);
|
69
|
}
|
70
|
|
71
|
|
72
|
if($this->cache->hget($keys[$x],'persistent')=='1')
|
73
|
{
|
74
|
$per1++;
|
75
|
$this->cache->del($keys[$x]);
|
76
|
}
|
77
|
|
78
|
|
79
|
if(strpos($query,'acronym')===true)
|
80
|
{
|
81
|
|
82
|
|
83
|
$this->cache->del($keys[$x]);
|
84
|
|
85
|
}
|
86
|
|
87
|
|
88
|
}
|
89
|
|
90
|
else
|
91
|
{
|
92
|
|
93
|
$this->cache->del($keys[$x]);
|
94
|
|
95
|
}
|
96
|
|
97
|
//echo("true: ".$pertrue." false : ".$perfalse." one ".$per1."\n\n");
|
98
|
|
99
|
|
100
|
}
|
101
|
|
102
|
|
103
|
}
|
104
|
|
105
|
}
|
106
|
|
107
|
echo("true: ".$pertrue." false : ".$perfalse." one ".$per1."datas".$datas."\n\n");
|
108
|
|
109
|
}
|
110
|
|
111
|
}
|
112
|
$rc = new TestClean();
|
113
|
$rc->test();
|
114
|
|
115
|
?>
|