Devographics / Devographics/Monorepo

Revalidate Redis survey definitions cache in background

Open
#212 0 comments 0 reactions 1 assignee Claimed by @eric-burel View on GitHub
enhancement surveyform
Dominant language
TypeScript
Stars
178
Forks
55
Avg merge
1m
Merged PRs (30d)
2

Description

Currently, when we want a survey definition or the list of survey:
- we look in the short-term (few minutes) in-memory cache for a promise, this handles peaks of // calls
- if not found, we trigger the data fetching workflow
- we look in the longer-term Redis cache (few hours)
- if not found, we look in the Github repo (source of truth)

Instead we should implement a Stale-While-Revalidate like strategy:
- initialize the Redis cache before the app is released, ideally as a build step or at least manually via the surveyadmin, instead of waiting for a runtime request
- trigger a Redis cache update in the background if the data are close to expiration. We can serve stale data for the current request (the github update can be time consuming)
- harder: trigger a Redis cache update if the github repo has been updated (we can probably get some timestamps from github? )

Also use this occasion to better document the local folder loading in "api-internal", namely for dev

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.