Project

General

Profile

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

    
6

    
7
class PromoteShadowNums {
8
	private $log;
9
	private $db;
10
	private $cache = null; //predis
11
	public function __construct(){
12
		
13
		global $redis_host;
14
		global $redis_port;
15
		global $redis_scheme;
16
		global $host;
17

    
18
		$this->log = Logger::getLogger(__CLASS__);
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
public function replace() 
39
{
40
 $shadowKeys=$this->cache->hkeys('SHADOW_STATS_NUMBERS');
41
 $this->log->info("moving shadow values to public for Stat Numbers...");
42

    
43
for($x=0;$x<count($shadowKeys);$x++)
44
{
45
	$key=$shadowKeys[$x];
46
	$value=$this->cache->hget('SHADOW_STATS_NUMBERS',$key);
47
	$this->cache->hset('STATS_NUMBERS',$key,$value); }
48

    
49
$this->log->info("All Shadow Entries Promoted Sucessfully!");
50
$this->cache->quit();
51
	}
52
}
53

    
54
?>
(19-19/28)