45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?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();
|
||
}
|
||
}
|
||
}
|