Files
webman-buildadmin/app/common/model/GameConfig.php
2026-04-20 10:31:14 +08:00

45 lines
1.1 KiB
PHP
Raw 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\GameHotDataRedis;
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 !== '') {
GameHotDataRedis::gameConfigForget($key);
}
if ($key === StreakWinReward::CONFIG_KEY) {
StreakWinReward::clearCache();
}
}
public static function onAfterDelete(GameConfig $model): void
{
$key = trim((string) ($model->getAttr('config_key') ?? ''));
if ($key !== '') {
GameHotDataRedis::gameConfigForget($key);
}
if ($key === StreakWinReward::CONFIG_KEY) {
StreakWinReward::clearCache();
}
}
}