Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Redis connection errors #611

Merged
merged 10 commits into from
Feb 12, 2024
Merged

Conversation

aviupadhyayula
Copy link
Member

@aviupadhyayula aviupadhyayula commented Feb 5, 2024

Adds flags to django_redis cache. Handles Redis connection errors silently, and falls back to DB when the cache is inaccessible. [1] Also adds socket timeouts on initial connection and subsequent requests. [2] This enables fast failures when the cache is down, instead of waiting indefinitely.

[1] https://github.com/jazzband/django-redis?tab=readme-ov-file#memcached-exceptions-behavior
[2] https://github.com/jazzband/django-redis?tab=readme-ov-file#socket-timeout

@aviupadhyayula aviupadhyayula marked this pull request as ready for review February 5, 2024 06:00
@aviupadhyayula aviupadhyayula marked this pull request as draft February 5, 2024 06:00
backend/clubs/utils.py Outdated Show resolved Hide resolved
@aviupadhyayula aviupadhyayula changed the title Implement custom cache manager Handle Redis connection errors Feb 12, 2024
@aviupadhyayula
Copy link
Member Author

aviupadhyayula commented Feb 12, 2024

Verified this works locally by pointing the development cache to an incorrect Redis host, and querying a route that relies on caching.

Unsure how (or if) to add a unit test for this. Would love to hear ideas.

@aviupadhyayula aviupadhyayula marked this pull request as ready for review February 12, 2024 00:23
@aviupadhyayula aviupadhyayula requested a review from rm03 February 12, 2024 00:27
@rohangpta rohangpta self-requested a review February 12, 2024 02:00
Copy link
Member

@rohangpta rohangpta left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the updates

@aviupadhyayula aviupadhyayula merged commit 505d127 into master Feb 12, 2024
7 checks passed
@aviupadhyayula aviupadhyayula deleted the avi/custom-cache-manager branch February 12, 2024 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants