Skip to content

Add caching layer for video analysis results #7

Description

@clencyc

Description

Analyzing the same video multiple times hits the Gemini API repeatedly and costs money. Implement Redis caching for analysis results.

Acceptance Criteria

  • Cache video analysis results by file hash (MD5)
  • Cache TTL: 7 days by default, configurable
  • Bypass cache with query param: ?skip_cache=true
  • Return cache hit status in response headers
  • Monitor cache hit/miss ratio
  • Clear cache command available
  • Redis integration tested
  • Saves API costs measurably

Implementation Details

  • Use Redis hash key: liveedit:analysis:{file_hash}
  • Store: analysis result + timestamp
  • Check cache in /api/analyze-video endpoint before calling Gemini
  • Add cache metrics endpoint: GET /api/cache/stats

Configuration

  • Add to .env: CACHE_TTL=604800 (7 days in seconds)
  • Add to .env: ENABLE_ANALYSIS_CACHE=true

Difficulty: Medium

Estimated time: 3-4 hours

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions