refactor(go): avoid duplicate realtime protocol payloads
This commit is contained in:
@@ -52,7 +52,7 @@ flowchart LR
|
||||
| MySQL | `vehicle_daily_mileage` | Queryable daily mileage | vin, date, protocol, daily mileage, source mileage | temporary vehicle keys, generic metric key/value rows, per-frame raw details |
|
||||
| MySQL | `vehicle_identity_binding` | Manual identity mapping | vin, plate, phone, device id | registration history |
|
||||
| MySQL | `jt808_registration` | JT808 registration and auth trace | phone, device id, plate, auth code, vin match state, first/latest seen | GB32960 or MQTT records |
|
||||
| Redis | `vehicle:latest:{vehicleKey}` | Latest merged realtime state | cross-protocol latest fields | historical data |
|
||||
| Redis | `vehicle:latest:{vehicleKey}` | Latest merged realtime state | cross-protocol latest fields only | full parsed payloads and historical data |
|
||||
| Redis | `vehicle:realtime-raw:{protocol}:{vehicleKey}` | Latest full realtime protocol state | latest protocol parsed payload | historical data |
|
||||
|
||||
## Event Envelope Rules
|
||||
|
||||
@@ -81,9 +81,9 @@ Redis 使用 DB 50,定位为实时缓存,不作为历史事实来源。
|
||||
|
||||
| Key 族 | 用途 |
|
||||
| --- | --- |
|
||||
| `vehicle:latest:{vehicleKey}` | 跨协议合并后的最新实时快照 |
|
||||
| `vehicle:latest:{vehicleKey}` | 跨协议合并后的最新核心字段快照,不重复保存完整 parsed |
|
||||
| `vehicle:latest:{vehicleKey}:{protocol}` | 单协议最新快照 |
|
||||
| `vehicle:realtime-raw:{protocol}:{vehicleKey}` | 单协议最新完整 parsed 状态 |
|
||||
| `vehicle:realtime-raw:{protocol}:{vehicleKey}` | 单协议最新完整 parsed 状态,是实时完整协议字段的唯一 Redis 副本 |
|
||||
| `vehicle:online:{vehicleKey}` | 在线状态和 TTL |
|
||||
| `vehicle:protocols:{vehicleKey}` | 当前车辆最近出现过的协议集合 |
|
||||
| `vehicle:last_seen` | 最近活跃车辆排序集合 |
|
||||
|
||||
@@ -638,7 +638,7 @@
|
||||
<thead><tr><th>接口类型</th><th>数据源</th><th>说明</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>VIN 是否在线</td><td>Redis online key</td><td>TTL 内有数据即在线,默认 TTL 600 秒。</td></tr>
|
||||
<tr><td>VIN 实时数据</td><td>Redis merged snapshot</td><td>跨协议合并 fields,并保留各协议 ProtocolData。</td></tr>
|
||||
<tr><td>VIN 实时数据</td><td>Redis latest snapshot</td><td>跨协议合并核心 fields;完整协议字段通过 realtime-raw 查询。</td></tr>
|
||||
<tr><td>单协议实时 RAW</td><td>Redis realtime-raw</td><td>查看某 VIN/phone 在某协议下最新 parsed 全量字段。</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -722,7 +722,7 @@
|
||||
</div>
|
||||
<div class="ok">
|
||||
<strong>实时多协议合并</strong><br>
|
||||
Redis 同时保留 latest snapshot、protocol snapshot、realtime-raw,既能看统一实时,也能追单协议原始字段。
|
||||
Redis latest snapshot 只保留统一实时核心字段;完整协议 parsed 只放 realtime-raw,避免重复缓存大 JSON。
|
||||
</div>
|
||||
<div class="ok">
|
||||
<strong>身份解析降级</strong><br>
|
||||
|
||||
Reference in New Issue
Block a user