修改缓存方式

This commit is contained in:
2026-04-20 10:31:14 +08:00
parent 025cce3e3e
commit 92fb40ae80
19 changed files with 512 additions and 57 deletions

View File

@@ -2,6 +2,7 @@
namespace app\common\model;
use app\common\service\GameHotDataRedis;
use support\think\Model;
/**
@@ -62,4 +63,20 @@ class User extends Model
{
return $this->where(['id' => $uid])->update(['password' => hash_password($newPassword)]);
}
public static function onAfterWrite(User $model): void
{
$id = filter_var($model->getAttr('id'), FILTER_VALIDATE_INT);
if ($id !== false && $id > 0) {
GameHotDataRedis::userForget($id);
}
}
public static function onAfterDelete(User $model): void
{
$id = filter_var($model->getAttr('id'), FILTER_VALIDATE_INT);
if ($id !== false && $id > 0) {
GameHotDataRedis::userForget($id);
}
}
}