-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(get_redis_clients): move this functionality to a central loc…
…ation this means we can stop writing the same code in two files while also avoiding circular imports
- Loading branch information
Showing
7 changed files
with
55 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Handle lazily creating redis clients in a central location.""" | ||
|
||
import redis | ||
|
||
from backend.config import settings | ||
|
||
|
||
def get_redis_queue_client(): | ||
"""Lazy initialization of the Redis queue client. | ||
Returns: | ||
A Redis queue client. | ||
""" | ||
if not hasattr(get_redis_queue_client, "client"): | ||
get_redis_queue_client.client = redis.StrictRedis.from_url(settings.redis_url, db=0, decode_responses=True) | ||
return get_redis_queue_client.client | ||
|
||
|
||
def get_redis_cache_client(): | ||
"""Lazy initialization of the Redis cache client. | ||
Returns: | ||
A Redis cache client. | ||
""" | ||
if not hasattr(get_redis_cache_client, "client"): | ||
get_redis_cache_client.client = redis.StrictRedis.from_url(settings.redis_url, db=1, decode_responses=True) | ||
return get_redis_cache_client.client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters