Skip to content

feat: implement client-side caching for GitHub API responses (closes #33)#54

Open
Ai-chan-0411 wants to merge 1 commit intoO2sa:mainfrom
Ai-chan-0411:feat/cache-github-api
Open

feat: implement client-side caching for GitHub API responses (closes #33)#54
Ai-chan-0411 wants to merge 1 commit intoO2sa:mainfrom
Ai-chan-0411:feat/cache-github-api

Conversation

@Ai-chan-0411
Copy link
Copy Markdown
Contributor

Summary

Implements server-side in-memory caching for GitHub API responses to reduce unnecessary API calls.

Changes

  • lib/cache.ts (new): Reusable InMemoryCache class with configurable TTL constants (1 day, 1 hour, 5 minutes)
  • lib/github.ts: Updated fetchGitHubUserData to check cache before making API calls; stores result for 1 day

How it works

  1. On each API request, the cache key github:user:{username} is checked first
  2. If a cached entry exists and hasn't expired, it's returned immediately (no API call)
  3. If not cached, the GitHub GraphQL API is called and the result is stored for 1 day
  4. Cache is case-insensitive (username normalized to lowercase)

Benefits

  • Reduces GitHub API calls for repeated lookups of the same user
  • Improves response time for cached users
  • Helps avoid GitHub API rate limits

Closes #33

…2sa#33)

Add in-memory cache with 1-day TTL to reduce GitHub API calls.
Cache keyed by username (case-insensitive) to avoid duplicate requests.
Extracted reusable InMemoryCache class in lib/cache.ts with configurable TTL constants.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 11, 2026

@Ai-chan-0411 is attempting to deploy a commit to the osama's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown

Thank you for the pull request! ✅

A maintainer will review this soon. Please be patient while we take a look. 🙌

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.

Implement caching for GitHub API responses

1 participant