python (3.12.0)
1 # SPDX-FileCopyrightText: 2015 Eric Larson
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 from .adapter import CacheControlAdapter
6 from .cache import DictCache
7
8
9 def CacheControl(
10 sess,
11 cache=None,
12 cache_etags=True,
13 serializer=None,
14 heuristic=None,
15 controller_class=None,
16 adapter_class=None,
17 cacheable_methods=None,
18 ):
19
20 cache = DictCache() if cache is None else cache
21 adapter_class = adapter_class or CacheControlAdapter
22 adapter = adapter_class(
23 cache,
24 cache_etags=cache_etags,
25 serializer=serializer,
26 heuristic=heuristic,
27 controller_class=controller_class,
28 cacheable_methods=cacheable_methods,
29 )
30 sess.mount("http://", adapter)
31 sess.mount("https://", adapter)
32
33 return sess