databases.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. use function Hyperf\Support\env;
  12. $pool = [
  13. 'min_connections' => 1,
  14. 'max_connections' => 10,
  15. 'connect_timeout' => 10.0,
  16. 'wait_timeout' => 3.0,
  17. 'heartbeat' => -1,
  18. 'max_idle_time' => (float)env('DB_MAX_IDLE_TIME', 60),
  19. ];
  20. $cache = [
  21. 'handler' => Hyperf\ModelCache\Handler\RedisHandler::class,
  22. 'cache_key' => '{mc:%s:m:%s}:%s:%s',
  23. 'prefix' => 'default',
  24. 'ttl' => 3600 * 24,
  25. 'empty_model_ttl' => 600,
  26. 'load_script' => true,
  27. ];
  28. $commands = [
  29. 'gen:model' => [
  30. 'path' => 'app/Model',
  31. 'force_casts' => true,
  32. 'inheritance' => 'Model',
  33. 'uses' => '',
  34. 'table_mapping' => [],
  35. ],
  36. ];
  37. return [
  38. 'default' => [
  39. 'driver' => env('DB_DRIVER', 'mysql'),
  40. 'host' => env('DB_HOST', 'localhost'),
  41. 'database' => env('DB_DATABASE', 'hyperf'),
  42. 'port' => env('DB_PORT', 3306),
  43. 'username' => env('DB_USERNAME', 'root'),
  44. 'password' => env('DB_PASSWORD', ''),
  45. 'charset' => env('DB_CHARSET', 'utf8'),
  46. 'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
  47. 'prefix' => env('DB_PREFIX', ''),
  48. 'pool' => $pool,
  49. 'cache' => $cache,
  50. 'commands' => $commands,
  51. ],
  52. 'robot' => [
  53. 'driver' => env('DB_DRIVER2', 'mysql'),
  54. 'host' => env('DB_HOST2', 'localhost'),
  55. 'database' => env('DB_DATABASE2', 'hyperf'),
  56. 'username' => env('DB_USERNAME2', 'root'),
  57. 'password' => env('DB_PASSWORD2', ''),
  58. 'charset' => env('DB_CHARSET', 'utf8'),
  59. 'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
  60. 'prefix' => env('DB_PREFIX2', ''),
  61. 'pool' => $pool,
  62. 'cache' => $cache,
  63. 'commands' => $commands,
  64. ],
  65. ];