优化性能
This commit is contained in:
@@ -27,4 +27,7 @@ return [
|
||||
'user_cache_prefix' => env('API_USER_CACHE_PREFIX', 'api:user:'),
|
||||
// 用户信息加密密钥(用于 Redis 中 value 的加密),建议 32 位
|
||||
'user_encrypt_key' => env('API_USER_ENCRYPT_KEY', 'dafuweng_api_user_cache_key_32'),
|
||||
// 玩家信息按 username 缓存(Token 中间件用),0 表示不缓存
|
||||
'player_cache_ttl' => (int) env('API_PLAYER_CACHE_TTL', 300),
|
||||
'player_cache_prefix' => env('API_PLAYER_CACHE_PREFIX', 'api:player:'),
|
||||
];
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
use support\Request;
|
||||
|
||||
return [
|
||||
'debug' => true,
|
||||
// 生产环境务必设为 false,减少 I/O 与堆栈输出,提升接口响应
|
||||
'debug' => env('APP_DEBUG', false),
|
||||
'error_reporting' => E_ALL,
|
||||
'default_timezone' => 'Asia/Shanghai',
|
||||
'request_class' => Request::class,
|
||||
|
||||
@@ -18,10 +18,10 @@ return [
|
||||
PDO::ATTR_EMULATE_PREPARES => false, // Must be false for Swoole and Swow drivers.
|
||||
],
|
||||
'pool' => [
|
||||
'max_connections' => 5,
|
||||
'min_connections' => 1,
|
||||
'wait_timeout' => 3,
|
||||
'idle_timeout' => 60,
|
||||
'max_connections' => (int) env('DB_POOL_MAX', 20),
|
||||
'min_connections' => (int) env('DB_POOL_MIN', 2),
|
||||
'wait_timeout' => (float) env('DB_POOL_WAIT_TIMEOUT', 1.0),
|
||||
'idle_timeout' => (int) env('DB_POOL_IDLE_TIMEOUT', 60),
|
||||
'heartbeat_interval' => 50,
|
||||
],
|
||||
],
|
||||
|
||||
@@ -20,7 +20,7 @@ return [
|
||||
'constructor' => [
|
||||
runtime_path() . '/logs/webman.log',
|
||||
7, //$maxFiles
|
||||
Monolog\Logger::DEBUG,
|
||||
env('LOG_LEVEL', Monolog\Logger::INFO),
|
||||
],
|
||||
'formatter' => [
|
||||
'class' => Monolog\Formatter\LineFormatter::class,
|
||||
|
||||
@@ -7,9 +7,9 @@ return [
|
||||
'port' => env('REDIS_PORT', 6379),
|
||||
'database' => env('REDIS_DB', 0),
|
||||
'pool' => [
|
||||
'max_connections' => 5,
|
||||
'min_connections' => 1,
|
||||
'wait_timeout' => 3,
|
||||
'max_connections' => (int) env('REDIS_POOL_MAX', 20),
|
||||
'min_connections' => (int) env('REDIS_POOL_MIN', 2),
|
||||
'wait_timeout' => (float) env('REDIS_POOL_WAIT_TIMEOUT', 1.0),
|
||||
'idle_timeout' => 60,
|
||||
'heartbeat_interval' => 50,
|
||||
],
|
||||
|
||||
@@ -24,13 +24,13 @@ return [
|
||||
'tag_expire' => 86400 * 30,
|
||||
// 缓存标签前缀
|
||||
'tag_prefix' => 'tag:',
|
||||
// 连接池配置
|
||||
// 连接池配置(与 redis.php 对齐,生产可调大以减少等待)
|
||||
'pool' => [
|
||||
'max_connections' => 5, // 最大连接数
|
||||
'min_connections' => 1, // 最小连接数
|
||||
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
|
||||
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
|
||||
'heartbeat_interval' => 50, // 心跳检测间隔,需要小于60秒
|
||||
'max_connections' => (int) env('REDIS_POOL_MAX', 20),
|
||||
'min_connections' => (int) env('REDIS_POOL_MIN', 2),
|
||||
'wait_timeout' => (float) env('REDIS_POOL_WAIT_TIMEOUT', 1.0),
|
||||
'idle_timeout' => 60,
|
||||
'heartbeat_interval' => 50,
|
||||
],
|
||||
],
|
||||
// 文件缓存
|
||||
|
||||
@@ -18,8 +18,7 @@ return [
|
||||
'hostport' => env('DB_PORT', 3306),
|
||||
// 数据库连接参数
|
||||
'params' => [
|
||||
// 连接超时3秒
|
||||
\PDO::ATTR_TIMEOUT => 3,
|
||||
\PDO::ATTR_TIMEOUT => (int) env('DB_CONNECT_TIMEOUT', 2),
|
||||
],
|
||||
// 数据库编码默认采用utf8
|
||||
'charset' => 'utf8',
|
||||
@@ -29,13 +28,13 @@ return [
|
||||
'break_reconnect' => true,
|
||||
// 自定义分页类
|
||||
'bootstrap' => '',
|
||||
// 连接池配置
|
||||
// 连接池配置(与 database.php 对齐)
|
||||
'pool' => [
|
||||
'max_connections' => 5, // 最大连接数
|
||||
'min_connections' => 1, // 最小连接数
|
||||
'wait_timeout' => 3, // 从连接池获取连接等待超时时间
|
||||
'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
|
||||
'heartbeat_interval' => 50, // 心跳检测间隔,需要小于60秒
|
||||
'max_connections' => (int) env('DB_POOL_MAX', 20),
|
||||
'min_connections' => (int) env('DB_POOL_MIN', 2),
|
||||
'wait_timeout' => (float) env('DB_POOL_WAIT_TIMEOUT', 1.0),
|
||||
'idle_timeout' => (int) env('DB_POOL_IDLE_TIMEOUT', 60),
|
||||
'heartbeat_interval' => 50,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user