https://github.com/do1e/apicache4shiro
https://github.com/do1e/apicache4shiro
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/do1e/apicache4shiro
- Owner: Do1e
- Created: 2025-05-02T10:17:51.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-05-02T12:10:56.000Z (about 1 year ago)
- Last Synced: 2025-05-07T04:59:22.162Z (about 1 year ago)
- Language: Python
- Homepage: https://www.do1e.cn/linkcard-test
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# API Cache for Shiro
用于缓存[Shiro](https://github.com/Innei/Shiro)中LinkCard的API请求,使用FastAPI和SQLite实现。
## 功能特点
- 基于FastAPI构建的高性能API代理服务
- 使用SQLite数据库进行本地缓存
- 支持多种API服务:Bangumi、GitHub、LeetCode、网易云音乐、QQ音乐、TMDB
- 为不同API设置不同的缓存时间
- 支持TMDB API的多语言缓存
- 支持Bangumi API的多语言翻译(为避免返回数据过慢,没有翻译缓存会首先返回原始文本,翻译完成后会更新缓存,在下次请求时返回翻译文本)
## 默认缓存时间配置
- Bangumi API: 5天
- GitHub API: 1天
- LeetCode API: 1天
- 音乐API: 30天
- TMDB API: 5天
## 使用
```
docker pull do1e/apicache4shiro
docker compose up -d
```
在Shiro的nginx配置靠前的未知添加:
```nginx
location ~ ^/api/(tmdb|bangumi|gh|leetcode|music) {
proxy_pass http://127.0.0.1:8000$request_uri;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
}
```
请注意,Bangumi翻译需要修改Shiro的代码,参考下述commit。
https://github.com/Do1e/Shiro/commit/73dd1f1567185abdb10df46988fdb79d24401031