mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-12-03 16:48:05 +09:00
## Summary
- Integrate karaoke-gen with flacfetch's new cache management API
(v0.15.4)
- When admins clear a job's cache, both Firestore AND flacfetch GCS
cache are now cleared
- Add bulk cache management (clear all, view stats) to admin UI
## Changes
### Backend
- **FlacfetchClient** (`backend/services/flacfetch_client.py`): Add
cache management methods
- `clear_search_cache(artist, title)` - clears specific cache entry
- `clear_all_cache()` - clears entire flacfetch cache
- `get_cache_stats()` - returns cache statistics
- **Admin API** (`backend/api/routes/admin.py`):
- Update `POST /api/admin/audio-searches/{job_id}/clear-cache` to also
call flacfetch cache API
- Add `DELETE /api/admin/cache` - clear entire flacfetch cache
- Add `GET /api/admin/cache/stats` - get cache statistics
### Frontend
- **API Client** (`frontend/lib/api.ts`): Add `clearAllCache()` and
`getCacheStats()` methods
- **Admin Searches Page** (`frontend/app/admin/searches/page.tsx`):
- Add "Clear All Cache" button with confirmation dialog
- Display cache stats (entry count, size, newest entry)
### Documentation
- Update API.md with new endpoints
- Update README.md with recent changes
- Update LESSONS-LEARNED.md with two-layer caching insight
## Architecture
```
User clicks "Clear Cache" on job
↓
karaoke-gen clears Firestore state_data (existing)
↓
karaoke-gen calls flacfetch DELETE /cache/search (NEW)
↓
flacfetch deletes GCS cache entry
↓
Next search hits trackers fresh ✓
```
## Testing
- [x] Backend tests pass (`make test` - 57 tests)
- [x] Frontend tests pass (`npm run test:unit` - 128 tests)
- [x] Frontend builds successfully
- [x] CodeRabbit CLI review completed locally
@coderabbitai ignore
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude <noreply@anthropic.com>