You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1.0 KiB

06 — DictQueryService + Caffeine 本地缓存

What to build: 业务模块读字典元数据的内部服务:按 (groupCode, itemCode) 反查项、查分组启用项列表、查分组当前默认项;Caffeine 本地缓存 expire-after-write=10s,空结果缓存 2 秒防穿透;变更写入不主动 evict,接受多副本 10 秒最终一致;dict_ref_count 绝不进缓存(DictQueryService 与 DictReferenceService API 分层)。HTTP enabled-list 端点改走本服务。

Blocked by: 04(与 05 并行)

Status: completed

  • DictQueryService 三方法可用,全部带缓存;空结果(不存在/空列表/无默认项)走 2s 负缓存
  • getItem 不按状态过滤(历史回显需要);listEnabledItems 双状态过滤
  • getDefaultItem 联查 group.status,分组停用返回 null
  • 项目启用项列表端点 GET /api/dict/item/enabled-list 改走 DictQueryService
  • 测试:改后重查可见新值(10s 内可能旧值)、空结果不穿透(2s 内重复查不打 DB)