Commit e9235b4
authored
fix(cache): DistributedCache.update() now writes to Redis on cold L1 … (JhaSourav07#3045)
## Description
Fixes JhaSourav07#3025
`DistributedCache.update()` was gating the Redis write behind a local L1
cache check.
On cold serverless instances (common on Vercel), the L1 cache is empty,
causing the
method to return `false` and silently skip the Redis update entirely —
leaving stale
data cached across all other instances indefinitely.
**Root cause:** `localCache.update()` returns `false` when the key isn't
in L1.
The early `if (!updated) return false` guard was preventing the Redis
write entirely.
**Fix:**
- Removed the L1 gate — L1 update is now best-effort
- Added `XX` flag to Redis `SET` command to preserve "only update
existing keys" semantics
- Fixed return value to reflect actual Redis response instead of
hardcoded `true`
- Fixed `catch` block to return `false` instead of silently swallowing
errors as `true`
## Pillar
- [ ] 🎨 Pillar 1 — New Theme Design
- [ ] 📐 Pillar 2 — Geometric SVG Improvement
- [ ] 🕐 Pillar 3 — Timezone Logic Optimization
- [X] 🛠️ Other (Bug fix, refactoring, docs)
## Checklist before requesting a review:
- [X] I have read the `CONTRIBUTING.md` file.
- [X] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
- [X] I have run `npm run format` and `npm run lint` locally and
resolved all errors (CI will fail otherwise).
- [X] My commits follow the Conventional Commits format (e.g.,
`feat(themes): ...`, `fix(calculate): ...`).
- [ ] I have updated `README.md` if I added a new theme or URL
parameter.
- [X] I have started the repo.
- [X] I have made sure that i have only one commit to merge in this PR.
- [ ] The SVG output matches the CommitPulse "premium quality" aesthetic
standard (no raw elements, smooth animations, correct fonts).
- [X] (Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.
Suggested labels: `bug`, `GSSoC 2026`, `intermediate`1 file changed
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
343 | | - | |
344 | | - | |
| 343 | + | |
345 | 344 | | |
346 | 345 | | |
347 | | - | |
| 346 | + | |
348 | 347 | | |
349 | 348 | | |
350 | 349 | | |
| |||
354 | 353 | | |
355 | 354 | | |
356 | 355 | | |
357 | | - | |
| 356 | + | |
358 | 357 | | |
359 | 358 | | |
360 | 359 | | |
361 | 360 | | |
362 | 361 | | |
363 | | - | |
| 362 | + | |
| 363 | + | |
364 | 364 | | |
365 | 365 | | |
366 | | - | |
| 366 | + | |
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
| |||
0 commit comments