Skip to content

feat: add TTL-based file-backed caching for GitHubCLIProvider#50

Open
Achiever199 wants to merge 1 commit into
Hell1213:mainfrom
Achiever199:feature/github-cache-layer
Open

feat: add TTL-based file-backed caching for GitHubCLIProvider#50
Achiever199 wants to merge 1 commit into
Hell1213:mainfrom
Achiever199:feature/github-cache-layer

Conversation

@Achiever199
Copy link
Copy Markdown

Summary

Closes #35

Adds an optional caching layer to GitHubCLIProvider to avoid
redundant gh CLI calls within and across sessions.

Changes

New file: src/oss_dev/providers/cache.py

  • CacheEntry — stores value + expiry timestamp
  • ResponseCache — two-layer cache (memory + disk)
    • Memory layer avoids repeated disk reads in the same process
    • Disk layer (JSON files) survives process restarts
    • TTL-based expiry on all entries
    • make_key() uses SHA-256 hashing for safe filenames

Modified: src/oss_dev/providers/github/client.py

  • Added _run_gh_cached() helper for read-only calls
  • Cached methods: fetch_issue, list_issues,
    get_pr_status, get_pr_comments
  • create_pr intentionally bypasses cache (mutating operation)
  • Cache controlled via config.cache.enabled / ttl / dir

New file: tests/providers/test_cache.py

  • 22 unit tests, all passing
  • Covers: TTL expiry, disk persistence, disabled mode,
    invalidation, provider integration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add caching layer for GitHub API responses

1 participant