{ "topic": "cache-three-problems", "type": "fill_blank", "schema_version": "1.0.0", "generated": "2026-09-05T00:00:00+08:00", "questions": [ { "id": "fb-001", "type": "fill_blank", "difficulty": 1, "tags": [ "缓存穿透" ], "question": "缓存穿透是指查询一个数据库中也______的数据,导致每次请求都直达数据库。", "answer": [ "不存在" ], "answer_rule": "any", "explanation": "缓存穿透的本质是查询的 key 在数据库中也【不存在】,缓存查不到、写不回,因此每次请求都要穿透到 DB。", "source": null, "related": [] }, { "id": "fb-002", "type": "fill_blank", "difficulty": 1, "tags": [ "缓存击穿" ], "question": "缓存击穿是______个热点 key 缓存【刚好过期】,大量请求同时打数据库,特点是单 key、高并发。", "answer": [ "一", "单", "1", "一个" ], "answer_rule": "any", "explanation": "击穿针对的是「单个特别热门的 key」刚过期,与穿透(不存在)和雪崩(成批)都不同,关键词是「单」。", "source": null, "related": [] }, { "id": "fb-003", "type": "fill_blank", "difficulty": 1, "tags": [ "缓存雪崩" ], "question": "缓存雪崩指______大批 key 在同一时刻集体失效,或整台缓存服务宕机,瞬时请求全部穿透到数据库。", "answer": [ "一批", "成批", "多个", "很多", "大量" ], "answer_rule": "any", "explanation": "雪崩的关键词是「多 key / 成批 / 集体失效」,与击穿的单 key 形成对比。", "source": null, "related": [] }, { "id": "fb-004", "type": "fill_blank", "difficulty": 2, "tags": [ "缓存穿透", "缓存空对象" ], "question": "用「缓存空对象」防穿透:DB 查不到时也缓存一个 null,并设置______(如 5 分钟)的 TTL。", "answer": [ "极短", "很短", "较短", "短" ], "answer_rule": "any", "explanation": "空值必须用极短 TTL,防止大量不同空 key 长期占用内存导致缓存爆掉。", "source": null, "related": [] }, { "id": "fb-005", "type": "fill_blank", "difficulty": 2, "tags": [ "缓存穿透", "布隆过滤器" ], "question": "布隆过滤器判断「不存在」时数据一定不存在(无______),判断「存在」时却可能存在(有______),且不支持删除。", "answer": [ "假阴性", "假阳性" ], "answer_rule": "ordered", "explanation": "布隆过滤器无假阴性(说不存在就一定不存在),有假阳性(说存在却可能不存在)。空按题目顺序填写「假阴性、假阳性」,因此 answer_rule 用 ordered。", "source": null, "related": [] }, { "id": "fb-006", "type": "fill_blank", "difficulty": 2, "tags": [ "缓存击穿", "互斥锁", "SETNX" ], "question": "用互斥锁解决击穿时,常用 Redis 的______命令实现分布式锁,保证同时只有一个请求回源数据库并回填缓存。", "answer": [ "SETNX", "setnx", "SET NX", "SETNXEX" ], "answer_rule": "any", "explanation": "SETNX(SET if Not eXists)是 Redis 实现分布式锁最常用的命令:抢到锁的请求才回源,其余等待或降级。", "source": null, "related": [] }, { "id": "fb-007", "type": "fill_blank", "difficulty": 3, "tags": [ "缓存击穿", "逻辑过期" ], "question": "「逻辑过期」方案不真正删除缓存,到期后由______异步线程去更新,保证数据持续可用。", "answer": [ "后台", "异步", "后台异步", "独立" ], "answer_rule": "any", "explanation": "逻辑过期由后台异步线程在后台刷新缓存,从而挡住所拦截的并发瞬时冲击,保证数据持续可用。", "source": null, "related": [] }, { "id": "fb-008", "type": "fill_blank", "difficulty": 3, "tags": [ "缓存雪崩", "TTL加随机" ], "question": "给缓存 key 的过期时间加______值(如 60+random(0~300) 秒),可把到期时刻打散,避免一批 key 同时失效。", "answer": [ "随机", "随机偏差", "随机数", "随机量" ], "answer_rule": "any", "explanation": "TTL 加随机值把各 key 的到期时间分散开,防止同一时刻集体失效的雪崩。", "source": null, "related": [] }, { "id": "fb-009", "type": "fill_blank", "difficulty": 4, "tags": [ "多级缓存", "缓存雪崩" ], "question": "多级缓存的访问顺序是:本地进程内缓存 → ______ → DB,层层兜底防雪崩。", "answer": [ "Redis", "分布式缓存", "缓存层", "分布式缓存层" ], "answer_rule": "any", "explanation": "典型多级缓存顺序为本地缓存(进程内)→ Redis(分布式缓存层)→ DB,逐层兜底,减小某层失效带来的冲击。", "source": null, "related": [] }, { "id": "fb-010", "type": "fill_blank", "difficulty": 4, "tags": [ "Redis高可用", "缓存雪崩" ], "question": "为避免整台缓存服务宕机引发雪崩,可采用______(主从+哨兵)或集群方案保证缓存层高可用。", "answer": [ "主从", "主从复制", "哨兵", "主从哨兵", "高可用架构" ], "answer_rule": "any", "explanation": "Redis 高可用通常由主从复制 + 哨兵(故障自动切换)+ 集群(分片)组成,避免整机宕机导致缓存雪崩。", "source": null, "related": [] } ] }