wrapper.py 754 B

123456789101112131415161718192021222324252627
  1. from .adapter import CacheControlAdapter
  2. from .cache import DictCache
  3. def CacheControl(sess,
  4. cache=None,
  5. cache_etags=True,
  6. serializer=None,
  7. heuristic=None,
  8. controller_class=None,
  9. adapter_class=None,
  10. cacheable_methods=None):
  11. cache = cache or DictCache()
  12. adapter_class = adapter_class or CacheControlAdapter
  13. adapter = adapter_class(
  14. cache,
  15. cache_etags=cache_etags,
  16. serializer=serializer,
  17. heuristic=heuristic,
  18. controller_class=controller_class,
  19. cacheable_methods=cacheable_methods
  20. )
  21. sess.mount('http://', adapter)
  22. sess.mount('https://', adapter)
  23. return sess