Skip to content

Missing caching for leaderboard API causes high database load Team: T134#21

Closed
dharm2112 wants to merge 4 commits intogdg-charusat:mainfrom
dharm2112:main
Closed

Missing caching for leaderboard API causes high database load Team: T134#21
dharm2112 wants to merge 4 commits intogdg-charusat:mainfrom
dharm2112:main

Conversation

@dharm2112
Copy link
Copy Markdown

Team Number : Team 134

Description

This PR adds a caching layer to the leaderboard API using a cache-aside pattern to reduce redundant database queries and improve performance.
Leaderboard data is cached with a 60-second TTL and invalidated on updates (submissions, score changes, member joins) to ensure consistency. Redis is used with an in-memory fallback for reliability.
This improves response time and scalability without introducing any breaking changes.

Related Issue

Closes #12

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Style/UI improvement

Changes Made

  • Added caching layer (Redis with in-memory fallback)
  • Implemented cache-aside pattern in leaderboard API
  • Added TTL (60 seconds) for cached leaderboard data
  • Implemented cache invalidation on:
    • new submissions
    • score updates
    • member joins
  • Added centralized cache service for better maintainability
  • Ensured fallback mechanism if Redis is unavailable
  • Added proper error handling to prevent cache-related failures

Testing

  • Tested API using Postman
  • Tested on Desktop (Chrome/Firefox/Safari)
  • Tested on Mobile (iOS/Android)
  • Tested responsive design (different screen sizes)
  • No console errors or warnings
  • Code builds successfully (npm run build)

Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my code
  • I have commented my code where necessary
  • My changes generate no new warnings
  • I have tested my changes thoroughly
  • All TypeScript types are properly defined
  • Tailwind CSS classes are used appropriately (no inline styles)
  • Component is responsive across different screen sizes
  • I have read and followed the CONTRIBUTING.md guidelines

Additional Notes

  • Redis is optional; if unavailable, the system automatically falls back to in-memory caching
  • No database schema changes were made
  • No API response format was changed
  • This is a performance optimization and does not introduce breaking changes

@krishnapaljadeja krishnapaljadeja self-requested a review February 22, 2026 11:04
@krishnapaljadeja krishnapaljadeja added the needs-review Valid issue-linked PR awaiting review label Feb 22, 2026
@krishnapaljadeja
Copy link
Copy Markdown
Contributor

✅ PR Validation Passed

Hey @dharm2112! Your PR looks good. Here is what we found:

Field Value
Team Number Team 134
Linked Issue Closes #12

A maintainer will review your PR within 24–48 hours. Stay responsive to feedback!

GDG CHARUSAT Open Source Contri Sprintathon

@krishnapaljadeja krishnapaljadeja added needs-review Valid issue-linked PR awaiting review and removed needs-review Valid issue-linked PR awaiting review labels Feb 23, 2026
@krishnapaljadeja krishnapaljadeja added needs-review Valid issue-linked PR awaiting review and removed needs-review Valid issue-linked PR awaiting review labels Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review Valid issue-linked PR awaiting review pr-noted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing caching for leaderboard API causes high database load Team: T134

2 participants