Skip to content

Instantly share code, notes, and snippets.

@yyong37
Created February 16, 2019 12:20
Show Gist options
  • Save yyong37/594bfe2aee4577b57dc10582ddb66bc4 to your computer and use it in GitHub Desktop.
Save yyong37/594bfe2aee4577b57dc10582ddb66bc4 to your computer and use it in GitHub Desktop.
<?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