Skip to content

add TTL#365

Merged
ViktorSvertoka merged 1 commit intomainfrom
develop
Feb 24, 2026
Merged

add TTL#365
ViktorSvertoka merged 1 commit intomainfrom
develop

Conversation

@ViktorSvertoka
Copy link
Member

@ViktorSvertoka ViktorSvertoka commented Feb 24, 2026

Summary by CodeRabbit

Release Notes

  • Performance Improvements
    • Extended cache duration for QA responses, improving response times and reducing server load through optimized caching.

@vercel
Copy link
Contributor

vercel bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
devlovers-net Ready Ready Preview, Comment Feb 24, 2026 7:24am

@netlify
Copy link

netlify bot commented Feb 24, 2026

Deploy Preview for develop-devlovers ready!

Name Link
🔨 Latest commit 03c191b
🔍 Latest deploy log https://app.netlify.com/projects/develop-devlovers/deploys/699d524176545400082141d6
😎 Deploy Preview https://deploy-preview-365--develop-devlovers.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

📝 Walkthrough

Walkthrough

The QA cache time-to-live constant was extended from 30 minutes to 30 days, allowing cached QA entries to persist significantly longer before expiration in the frontend caching layer.

Changes

Cohort / File(s) Summary
Cache TTL Configuration
frontend/lib/cache/qa.ts
Increased QA_CACHE_TTL_SECONDS from 1800 seconds (30 minutes) to 2592000 seconds (30 days), extending cache persistence duration for QA data.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Suggested labels

backend

Suggested reviewers

  • AM1007

Poem

🐰 Thirty days now, not thirty mere,
QA cache blooms throughout the year!
Swift answers linger, fresh and bright,
Less queries needed, pure delight! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'add TTL' is vague and generic, not clearly indicating what TTL was added or why. Replace with a more specific title such as 'Increase QA cache TTL from 30 minutes to 30 days' to clearly describe the actual change.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch develop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/lib/cache/qa.ts (1)

55-66: ⚠️ Potential issue | 🟠 Major

Category invalidation won’t match versioned keys.
buildQaCacheKey prefixes keys with qa:${QA_CACHE_VERSION}:…, but invalidateQaCacheByCategory scans qa:category:…. This likely leaves cache entries undeleted; with the new 30‑day TTL, stale data can linger much longer.

🛠️ Suggested fix
-  const prefix = `qa:category:${category.toLowerCase()}:`;
+  const prefix = `qa:${QA_CACHE_VERSION}:category:${category.toLowerCase()}:`;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/lib/cache/qa.ts` around lines 55 - 66, invalidateQaCacheByCategory
is scanning for keys starting with "qa:category:…" but buildQaCacheKey and
stored keys include the version prefix (QA_CACHE_VERSION) so the scan misses
entries; update invalidateQaCacheByCategory to construct the scan match with the
same versioned prefix (e.g. include QA_CACHE_VERSION) or use buildQaCacheKey to
derive the prefix (qa:${QA_CACHE_VERSION}:category:${category.toLowerCase()}:)
so the redis.scan match targets the exact versioned keys and deleted count
correctly removes stale cache entries; keep using getRedisClient and the same
scan loop logic.
🧹 Nitpick comments (1)
frontend/lib/cache/qa.ts (1)

4-4: Consider making the 30‑day TTL configurable.
Hardcoding such a long TTL makes operational tuning harder (e.g., during incident response or A/B testing). Prefer an env override with a safe default.

♻️ Suggested tweak
-const QA_CACHE_TTL_SECONDS = 60 * 60 * 24 * 30;
+const QA_CACHE_TTL_SECONDS =
+  Number(process.env.QA_CACHE_TTL_SECONDS ?? 60 * 60 * 24 * 30);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/lib/cache/qa.ts` at line 4, Replace the hardcoded
QA_CACHE_TTL_SECONDS constant with a configurable value sourced from an
environment variable (e.g., QA_CACHE_TTL_SECONDS) and fall back to the current
30-day default if the env var is missing or invalid; update the declaration of
QA_CACHE_TTL_SECONDS to parse and validate the env value (using Number/parseInt
and a NaN check or safe default) so runtime/ops can override TTL for QA cache
without code changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@frontend/lib/cache/qa.ts`:
- Around line 55-66: invalidateQaCacheByCategory is scanning for keys starting
with "qa:category:…" but buildQaCacheKey and stored keys include the version
prefix (QA_CACHE_VERSION) so the scan misses entries; update
invalidateQaCacheByCategory to construct the scan match with the same versioned
prefix (e.g. include QA_CACHE_VERSION) or use buildQaCacheKey to derive the
prefix (qa:${QA_CACHE_VERSION}:category:${category.toLowerCase()}:) so the
redis.scan match targets the exact versioned keys and deleted count correctly
removes stale cache entries; keep using getRedisClient and the same scan loop
logic.

---

Nitpick comments:
In `@frontend/lib/cache/qa.ts`:
- Line 4: Replace the hardcoded QA_CACHE_TTL_SECONDS constant with a
configurable value sourced from an environment variable (e.g.,
QA_CACHE_TTL_SECONDS) and fall back to the current 30-day default if the env var
is missing or invalid; update the declaration of QA_CACHE_TTL_SECONDS to parse
and validate the env value (using Number/parseInt and a NaN check or safe
default) so runtime/ops can override TTL for QA cache without code changes.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b90a96a and 03c191b.

📒 Files selected for processing (1)
  • frontend/lib/cache/qa.ts

@ViktorSvertoka ViktorSvertoka merged commit 27aeabb into main Feb 24, 2026
15 checks passed
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.

1 participant