Skip to content

Commit d5f95a1

Browse files
committed
Allow using an empty cache for development
1 parent c80cff0 commit d5f95a1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ordering/caching.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66

77
from ordering.settings import REDIS_URL
88

9-
10-
cache = Redis.from_url(REDIS_URL)
119
logger = getLogger(__name__)
1210

11+
try:
12+
cache = Redis.from_url(REDIS_URL)
13+
except ValueError:
14+
logger.warning("Unable to open cache. Caching will be disabled.", exc_info=True)
15+
cache = None
16+
17+
1318

1419
def serialized_response(response):
1520
def handle_bytes(value):
@@ -23,6 +28,10 @@ def handle_bytes(value):
2328

2429
def safe_cache_content(timeout=None, backup=False, hash_args=False):
2530
def decorator(func):
31+
32+
if cache is None:
33+
return func
34+
2635
@wraps(func)
2736
def wrapper(*args, **kwargs):
2837
inputs = f'{args}-{kwargs}'

0 commit comments

Comments
 (0)