Skip to content

Commit

Permalink
Move redis import location to prevent import errors when not available.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtibbles committed Mar 14, 2024
1 parent a9276dd commit 7b5c745
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions kolibri/core/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,15 @@ def check_redis_settings(): # noqa C901
if we are configured to do so, and if we should, otherwise make some logging noise.
"""

from redis.exceptions import ConnectionError

if OPTIONS["Cache"]["CACHE_BACKEND"] != "redis":
return

# Don't import until we've confirmed we're using Redis
# to avoid a hard dependency on Redis
# the options config has already been validated at this point
# so we know that redis is available.
from redis.exceptions import ConnectionError

config_maxmemory = OPTIONS["Cache"]["CACHE_REDIS_MAXMEMORY"]
config_maxmemory_policy = OPTIONS["Cache"]["CACHE_REDIS_MAXMEMORY_POLICY"]

Expand Down

0 comments on commit 7b5c745

Please sign in to comment.