From d15c03c04e33a23b7d0aff0fe39881650851c587 Mon Sep 17 00:00:00 2001 From: ctexthuang Date: Sat, 26 Oct 2024 16:26:10 +0800 Subject: [PATCH] feat: config --- composer.json | 3 +++ config/autoload/ali.php | 30 ++++++++++++++++++++++++++++++ config/autoload/crontab.php | 18 ++++++++++++++++++ config/autoload/databases.php | 11 +++++++++++ config/autoload/redis.php | 28 ++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+) create mode 100644 config/autoload/ali.php create mode 100644 config/autoload/crontab.php diff --git a/composer.json b/composer.json index 4f4cb32..10d6083 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,8 @@ "license": "Apache-2.0", "require": { "php": ">=8.3", + "alibabacloud/sts-20150401": "^1.1", + "aliyuncs/oss-sdk-php": "^2.7", "firebase/php-jwt": "^6.10", "hyperf/amqp": "~3.1.0", "hyperf/cache": "~3.1.0", @@ -28,6 +30,7 @@ "hyperf/http-server": "~3.1.0", "hyperf/logger": "~3.1.0", "hyperf/memory": "~3.1.0", + "hyperf/model-cache": "^3.1", "hyperf/paginator": "^3.1", "hyperf/process": "~3.1.0", "hyperf/redis": "~3.1.0", diff --git a/config/autoload/ali.php b/config/autoload/ali.php new file mode 100644 index 0000000..2d55ae5 --- /dev/null +++ b/config/autoload/ali.php @@ -0,0 +1,30 @@ + env('ALI_ACCESS_KEY_ID', ''), + // 阿里云 accessKeySecret + 'access_key_secret' => env('ALI_ACCESS_KEY_SECRET', ''), + // 阿里云 oss bucket + 'bucket' => env('ALI_BUCKET', ''), + // 阿里云 oss region + 'region' => env('ALI_REGION', 'cn-shenzhen'), + // 阿里云 oss 临时上传目录 + 'upload_dir' => env('ALI_UPLOAD_DIR', ''), + // 阿里云 oss 回调地址 + 'callback_url' => env('ALI_CALLBACK_URL', ''), + // 阿里云 oss 外网访问地址 + 'oss_url' => env('ALI_OSS_URL', ''), +]; \ No newline at end of file diff --git a/config/autoload/crontab.php b/config/autoload/crontab.php new file mode 100644 index 0000000..c9ab2ec --- /dev/null +++ b/config/autoload/crontab.php @@ -0,0 +1,18 @@ + env('CRONTAB_ENABLE', false), +]; \ No newline at end of file diff --git a/config/autoload/databases.php b/config/autoload/databases.php index 79c013e..1d5ec96 100644 --- a/config/autoload/databases.php +++ b/config/autoload/databases.php @@ -9,6 +9,8 @@ declare(strict_types=1); * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + +use Hyperf\ModelCache\Handler\RedisHandler; use function Hyperf\Support\env; return [ @@ -37,5 +39,14 @@ return [ 'inheritance' => 'Model', ], ], + 'cache' => [ + 'handler' => RedisHandler::class, + 'cache_key' => 'mc:%s:m:%s:%s:%s', + 'prefix' => 'default', + 'ttl' => 3600 * 24, + 'empty_model_ttl' => 3600, + 'load_script' => true, + 'use_default_value' => false, + ] ], ]; diff --git a/config/autoload/redis.php b/config/autoload/redis.php index 8810f81..6e48615 100644 --- a/config/autoload/redis.php +++ b/config/autoload/redis.php @@ -26,4 +26,32 @@ return [ 'max_idle_time' => (float) env('REDIS_MAX_IDLE_TIME', 60), ], ], + 'system' => [ + 'host' => env('REDIS_HOST', 'localhost'), + 'auth' => env('REDIS_AUTH', null), + 'port' => (int) env('REDIS_PORT', 6379), + 'db' => (int) env('SYSTEM_REDIS_DB', 1), + 'pool' => [ + 'min_connections' => 1, + 'max_connections' => 10, + 'connect_timeout' => 10.0, + 'wait_timeout' => 3.0, + 'heartbeat' => -1, + 'max_idle_time' => (float) env('REDIS_MAX_IDLE_TIME', 60), + ], + ], + 'lock' => [ + 'host' => env('REDIS_HOST', 'localhost'), + 'auth' => env('REDIS_AUTH', null), + 'port' => (int) env('REDIS_PORT', 6379), + 'db' => (int) env('LOCK_REDIS_DB', 2), + 'pool' => [ + 'min_connections' => 1, + 'max_connections' => 10, + 'connect_timeout' => 10.0, + 'wait_timeout' => 3.0, + 'heartbeat' => -1, + 'max_idle_time' => (float) env('REDIS_MAX_IDLE_TIME', 60), + ], + ], ];