|
@@ -52,6 +52,26 @@ class Store
|
|
|
}
|
|
}
|
|
|
return self::$instance[$config_name];
|
|
return self::$instance[$config_name];
|
|
|
}
|
|
}
|
|
|
|
|
+ // redis 驱动
|
|
|
|
|
+ elseif(\Config\Store::$driver == \Config\Store::DRIVER_REDIS)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(!isset(\Config\Store::$$config_name))
|
|
|
|
|
+ {
|
|
|
|
|
+ echo "\\Config\\Store::$config_name not set\n";
|
|
|
|
|
+ throw new \Exception("\\Config\\Store::$config_name not set\n");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!isset(self::$instance[$config_name]))
|
|
|
|
|
+ {
|
|
|
|
|
+ self::$instance[$config_name] = new \GatewayWorker\Lib\StoreDriver\Redis();
|
|
|
|
|
+ // 只选择第一个ip作为服务端
|
|
|
|
|
+ $address = current(\Config\Store::$$config_name);
|
|
|
|
|
+ list($ip, $port) = explode(':', $address);
|
|
|
|
|
+ $timeout = 1;
|
|
|
|
|
+ self::$instance[$config_name]->connect($ip, $port, $timeout);
|
|
|
|
|
+ self::$instance[$config_name]->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_IGBINARY);
|
|
|
|
|
+ }
|
|
|
|
|
+ return self::$instance[$config_name];
|
|
|
|
|
+ }
|
|
|
// 文件驱动
|
|
// 文件驱动
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|