fix: 设备变更时同步清除用户缓存,修复 user_devices 为空问题
Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled

Device.GetCacheKeys() 新增 cacheUserIdPrefix+UserId,
确保 InsertDevice/UpdateDevice/DeleteDevice 时同时失效
cache:user:id:{userId},避免下次 FindOne 读到不含
UserDevices 的旧缓存。

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
shanshanzhong 2026-03-31 05:28:05 -07:00
parent abc9864d46
commit 98972401c2

View File

@ -102,6 +102,9 @@ func (d *Device) GetCacheKeys() []string {
if d.Identifier != "" { if d.Identifier != "" {
keys = append(keys, fmt.Sprintf("%s%s", cacheUserDeviceNumberPrefix, d.Identifier)) keys = append(keys, fmt.Sprintf("%s%s", cacheUserDeviceNumberPrefix, d.Identifier))
} }
if d.UserId != 0 {
keys = append(keys, fmt.Sprintf("%s%d", cacheUserIdPrefix, d.UserId))
}
return keys return keys
} }