Files
webman-buildadmin/app/common/model/GameConfig.php
zhenhui 1eed3cf0f7 1.增加互斥锁:保证缓存和数据库数据一致性
2.增加消费队列,保证mysql数据的正常保存
2026-04-20 14:13:48 +08:00

45 lines
1.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace app\common\model;
use app\common\library\game\StreakWinReward;
use app\common\service\GameHotDataCoordinator;
use support\think\Model;
/**
* 游戏/平台动态参数KV
*/
class GameConfig extends Model
{
protected $name = 'game_config';
protected $autoWriteTimestamp = true;
protected $type = [
'create_time' => 'integer',
'update_time' => 'integer',
];
public static function onAfterWrite(GameConfig $model): void
{
$key = trim((string) ($model->getAttr('config_key') ?? ''));
if ($key !== '') {
GameHotDataCoordinator::afterGameConfigKeyCommitted($key);
}
if ($key === StreakWinReward::CONFIG_KEY) {
StreakWinReward::clearCache();
}
}
public static function onAfterDelete(GameConfig $model): void
{
$key = trim((string) ($model->getAttr('config_key') ?? ''));
if ($key !== '') {
GameHotDataCoordinator::afterGameConfigKeyCommitted($key);
}
if ($key === StreakWinReward::CONFIG_KEY) {
StreakWinReward::clearCache();
}
}
}