Class phpredis extends redis{ //redis default of 16 sheets static $dbs = array (' 0 ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' 10 ', ' 11 ', ' 12 ', ' 13 ', ' 14 ', ' 15 ',); public function __construct () { try{ // Redis host, connection Port $this->connect ($redis _ cachehost, $redis _cacheport); // Connection Password $this->auth ($redis _passport); }cache (exception $e) { log_message (' redis error ', $e->__tostring (), ' REDIS '); } } //Static instantiation static private $obCore = "; static function getinstance () { if (self:: $obCore == null) { self:: $obCore = new self (); } Return self:: $obCore; }}//attached: Log_message () method, used to generate the log file Function log_message ($ type, $var, $file = ") { $dir = ROOT . '/log/'; //root for Root if (! $file) { $dir .= date ("Y") . '/' . date (" M ") . '/' . date (' d '); mkdirs ($dir); $file = $dir . '/' . date ("YMD") . ". Log"; } else { $file = $dir . TEMPLATE . ' _ ' . $file . '. Log '; } $sh = fopen ($file, "a"); $var = "[$type] " . date (' y-m-d h:i:s ') . ' : ' . $var . " \ n "; fwrite ($sh, $var, strlen ($var)); fclose ($SH);}
References to Redis