Harshdev625 / Harshdev625/TimeMachine

Add Redis caching for session endpoints to improve performance

未关闭
#61 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement hacktoberfest
主要语言
JavaScript
星标
12
派生
28
PR 合并指标
30 天内没有已合并 PR

描述

## Problem Statement

- Currently, every time the user refreshes their dashboard or checks session history, the backend fetches data directly from MongoDB.
- This increases response time and database load, especially when users frequently start, pause, or complete sessions.

## Proposed Solution

- Add a Redis caching layer to temporarily store frequently accessed session data (/current, /history) for faster retrieval.

## Implementation idea:

- Use ioredis or redis npm package.

- Cache key format: session:${userEmail}

- Set a TTL of 5–10 minutes.

- Invalidate cache whenever session data is created, updated, or deleted.

## Alternatives Considered

- Using in-memory caching (e.g., node-cache) — but it wouldn’t scale across multiple backend instances.

- MongoDB indexing — helps query speed but doesn’t reduce repeated hits.

## Additional Context

- This would improve user experience on dashboards and analytics pages, reducing API response times by 30–50% while easing database loa

贡献指南

打开贡献指南

调研方向

Start by locating the backend handlers for /current and /history, the MongoDB session access, and the create, update, and delete paths. Check the existing package setup before choosing ioredis or redis. Done means the endpoints use the specified session cache with a 5–10 minute TTL and cache entries are invalidated whenever session data changes.

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, mongodb, redis
领域
backend, databases, performance
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。