databases.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 Hyperf\ModelCache\Handler\RedisHandler;
  12. use function Hyperf\Support\env;
  13. return [
  14. 'default' => [
  15. 'driver' => env('DB_DRIVER', 'mysql'),
  16. 'host' => env('DB_HOST', 'localhost'),
  17. 'port' => env('DB_PORT', '3306'),
  18. 'database' => env('DB_DATABASE', 'hyperf'),
  19. 'username' => env('DB_USERNAME', 'root'),
  20. 'password' => env('DB_PASSWORD', ''),
  21. 'charset' => env('DB_CHARSET', 'utf8'),
  22. 'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
  23. 'prefix' => env('DB_PREFIX', ''),
  24. 'pool' => [
  25. 'min_connections' => 1,
  26. 'max_connections' => 10,
  27. 'connect_timeout' => 10.0,
  28. 'wait_timeout' => 3.0,
  29. 'heartbeat' => -1,
  30. 'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
  31. ],
  32. 'cache' => [
  33. 'handler' => RedisHandler::class,
  34. 'cache_key' => 'mc:%s:m:%s:%s:%s',
  35. 'prefix' => 'default',
  36. 'ttl' => 3600 * 24,
  37. 'load_script' => true,
  38. ],
  39. 'commands' => [
  40. 'gen:model' => [
  41. 'path' => 'app/Model',
  42. 'force_casts' => true,
  43. 'inheritance' => 'Model',
  44. ],
  45. ],
  46. ],
  47. ];