You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
844 B
41 lines
844 B
<?php
|
|
namespace App\Libs;
|
|
|
|
use SSDB;
|
|
use SimpleSSDB;
|
|
class SsdbClient
|
|
{
|
|
public $SSDB;
|
|
|
|
//public function __construct()
|
|
//{
|
|
// $host = env('SSDB_HOST');
|
|
// $port = env('SSDB_PORT');
|
|
//
|
|
// try{
|
|
// $SSDB = new SimpleSSDB($host, $port);
|
|
// $SSDB->auth(env('SSDB_AUTH'));
|
|
// }catch(\Exception $e){
|
|
// dd($e);
|
|
// }
|
|
//}
|
|
|
|
|
|
/**
|
|
* @throws \Exception
|
|
*/
|
|
public static function client($host=null, $port=null)
|
|
{
|
|
$host = $host??env('SSDB_HOST');
|
|
$port = $port??env('SSDB_PORT');
|
|
|
|
try {
|
|
$SSDB = new SimpleSSDB($host, $port);
|
|
$SSDB->auth(env('SSDB_AUTH'));
|
|
} catch (\Exception $e) {
|
|
throw new \Exception('SSDB:' . $e->getMessage());
|
|
}
|
|
|
|
return $SSDB;
|
|
}
|
|
}
|