Skip to content

Switch database from in-memory to Redis#5

Open
sunilagwl5 wants to merge 4 commits intomainfrom
chore/handoff-redis-migration-analysis-NRtrrp
Open

Switch database from in-memory to Redis#5
sunilagwl5 wants to merge 4 commits intomainfrom
chore/handoff-redis-migration-analysis-NRtrrp

Conversation

@sunilagwl5
Copy link
Owner

Summary

This pull request replaces the existing in-memory data storage mechanism with Redis as the primary database. This change is necessary to persist data across application restarts and improve scalability.

Configuration for Redis connection is expected to be provided via environment variables (REDIS_URL, REDISHOST, REDISPASSWORD, REDISPORT, REDISUSER).

Changes

  • Added redis dependency to requirements.txt to support Redis operations.
  • Updated main.py to initialize and use a Redis client instead of in-memory lists/variables.
    • Imported redis and json.
    • Introduced get_redis_client() function to establish the connection using environment variables (specifically checking for REDIS_URL).
    • Removed in-memory storage variables (items: List[Item] = [], current_id = 0).

Notes for Reviewers

The implementation for CRUD operations (GET, POST, PUT, DELETE) using Redis is not yet complete in the provided diffs, as the focus here is solely on setting up the Redis connection infrastructure. Reviewers should confirm the environment variable handling for Redis connection is robust.

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