Bläddra i källkod

add RedisCluster

visuddhinanda 2 år sedan
förälder
incheckning
f8b0b721c2
1 ändrade filer med 11 tillägg och 5 borttagningar
  1. 11 5
      public/app/redis/function.php

+ 11 - 5
public/app/redis/function.php

@@ -3,17 +3,23 @@ require_once __DIR__."/../config.php";
 function redis_connect()
 {
 	try {
-		//code...
-		$redis = new redis();
-		$r_conn = $redis->connect(Redis["host"], Redis["port"]);
+        $server = $_SERVER['SERVER_NAME'];
+        if(strpos($server,'wikipali') === false){
+            //local dev
+            $redis = new redis();
+            $r_conn = $redis->connect(Redis["host"], Redis["port"]);
+        }else{
+            $redis = new RedisCluster(NULL,Array(Redis["host"].':'.Redis["port"]));
+            $r_conn = true;
+        }
 		if ($r_conn) {
 			if(Redis["password"] !== ""){
 				$redis->auth(Redis["password"]);
-			}		
+			}
 			return $redis;
 		} else {
 			return false;
-		}		
+		}
 	} catch (\Throwable $th) {
 		//throw $th;
 		return false;