Created
February 16, 2019 12:20
-
-
Save yyong37/594bfe2aee4577b57dc10582ddb66bc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Singleton { | |
private $_instance; | |
private function __construct() {} | |
private function __clone() {} | |
public function getInstance() { | |
if(!self::$_instance instanceof self) { | |
self::$_instance = new self; | |
} | |
return (self::$_instance)->connectRedis(); | |
} | |
public function connectRedis() { | |
try { | |
$redis = new Redis(); | |
$redis_ocean->connect(G::$conf['redis-host'], G::$conf['redis-port']); | |
$redis_ocean->auth(G::$conf['redis-pass']); | |
}catch(Exception $e) { | |
echo $e->getMessage(); | |
} | |
return $redisConn; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment