Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Commit

Permalink
Merge pull request #231 from dimagi/redis
Browse files Browse the repository at this point in the history
new style for getting redis client
  • Loading branch information
biyeun committed Dec 4, 2014
2 parents c74e296 + a77af69 commit 4b76e7d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dimagi/utils/couch/cache/cache_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,17 @@ def get_redis_default_cache():
except (InvalidCacheBackendError, ValueError):
return cache.cache


def get_redis_client():
if not REDIS_CACHE:
raise RedisClientError("No redis cache defined in settings")

try:
client = REDIS_CACHE.raw_client
try:
client = REDIS_CACHE.raw_client
except AttributeError:
# version >= 3.8.0
client = REDIS_CACHE.client.get_client()
except Exception:
log.error("Could not get redis connection.", exc_info=True)
raise RedisClientError("Could not get redis connection.")
Expand Down

0 comments on commit 4b76e7d

Please sign in to comment.