链街Dcat后台
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

  1. <?php
  2. namespace App\Libs;
  3. use SSDB;
  4. use SimpleSSDB;
  5. class SsdbClient
  6. {
  7. public $SSDB;
  8. //public function __construct()
  9. //{
  10. // $host = env('SSDB_HOST');
  11. // $port = env('SSDB_PORT');
  12. //
  13. // try{
  14. // $SSDB = new SimpleSSDB($host, $port);
  15. // $SSDB->auth(env('SSDB_AUTH'));
  16. // }catch(\Exception $e){
  17. // dd($e);
  18. // }
  19. //}
  20. /**
  21. * @throws \Exception
  22. */
  23. public static function client($host=null, $port=null)
  24. {
  25. $host = $host??env('SSDB_HOST');
  26. $port = $port??env('SSDB_PORT');
  27. try {
  28. $SSDB = new SimpleSSDB($host, $port);
  29. $SSDB->auth(env('SSDB_AUTH'));
  30. } catch (\Exception $e) {
  31. throw new \Exception('SSDB:' . $e->getMessage());
  32. }
  33. return $SSDB;
  34. }
  35. }