Skip to content

fix : added TTL-based cache invalidation to data_loader - #1323

Open
tmdeveloper007 wants to merge 1 commit into
komalharshita:mainfrom
tmdeveloper007:#1318
Open

fix : added TTL-based cache invalidation to data_loader#1323
tmdeveloper007 wants to merge 1 commit into
komalharshita:mainfrom
tmdeveloper007:#1318

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Summary of What Has Been Done

Added time-based cache expiration to load_all_projects() in src/utils/data_loader.py so the in-memory project cache does not serve stale data indefinitely.

Changes Made

  • Added _projects_cache_time global to track when the cache was last populated
  • Added _CACHE_TTL_SECONDS = 300 (5-minute TTL constant)
  • Added _cache_expired() helper that returns True when the cache is missing or older than the TTL
  • Updated load_all_projects() to use _cache_expired() instead of a bare None check, and to record time.time() on cache miss
  • Updated clear_cache() to also reset _projects_cache_time to 0

Impact it Made

Users will always see project data that is at most 5 minutes old instead of potentially stale cached data from when the app started. This fixes a data consistency bug where database updates were invisible to running instances.

Note: Please assign this PR to the tmdeveloper007 account.

Closes #1318

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

@tmdeveloper007 is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel.

A member of the Team first needs to authorize it.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix : data_loader cache never invalidates on database updates

1 participant