Skip to content

Commit c60fb2f

Browse files
author
Jaap Roes
committed
Test if cache is None before falling back to DictCache
This allows passing in a cache instance that is falsy
1 parent cd91309 commit c60fb2f

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

cachecontrol/adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(
2424
**kw
2525
):
2626
super(CacheControlAdapter, self).__init__(*args, **kw)
27-
self.cache = cache or DictCache()
27+
self.cache = DictCache() if cache is None else cache
2828
self.heuristic = heuristic
2929
self.cacheable_methods = cacheable_methods or ("GET",)
3030

cachecontrol/controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CacheController(object):
3434
def __init__(
3535
self, cache=None, cache_etags=True, serializer=None, status_codes=None
3636
):
37-
self.cache = cache or DictCache()
37+
self.cache = DictCache() if cache is None else cache
3838
self.cache_etags = cache_etags
3939
self.serializer = serializer or Serializer()
4040
self.cacheable_status_codes = status_codes or (200, 203, 300, 301)

cachecontrol/wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def CacheControl(
1313
cacheable_methods=None,
1414
):
1515

16-
cache = cache or DictCache()
16+
cache = DictCache() if cache is None else cache
1717
adapter_class = adapter_class or CacheControlAdapter
1818
adapter = adapter_class(
1919
cache,

0 commit comments

Comments
 (0)