Skip to content

[Feature] Add Redis caching for improved performance #16

Description

@lechan775

Problem

高频接口每次请求都查询数据库:

  • 单词列表 (/api/words?bookId=) — 词书数据基本不变
  • 学习统计 (/api/stats/overview) — 可按 userId 缓存短时
  • 词书进度 (/api/books/progress) — 频繁更新但可短期缓存

Proposed Solution

  1. 引入 Spring Cache + Redis:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
  1. 缓存策略:

    • words — 按 bookId 缓存,TTL 1 小时,词书更新时失效
    • stats — 按 userId 缓存,TTL 5 分钟
    • books — 按 userId 缓存,TTL 10 分钟,学习记录写入时部分失效
  2. Docker Compose 中增加 Redis 容器

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions