1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 """Caching utility for the discovery document."""
16
17 from __future__ import absolute_import
18
19 import logging
20 import datetime
21
22
23 LOGGER = logging.getLogger(__name__)
24
25 DISCOVERY_DOC_MAX_AGE = 60 * 60 * 24
26
27
29 """Detects an appropriate cache module and returns it.
30
31 Returns:
32 googleapiclient.discovery_cache.base.Cache, a cache object which
33 is auto detected, or None if no cache object is available.
34 """
35 try:
36 from google.appengine.api import memcache
37 from . import appengine_memcache
38
39 return appengine_memcache.cache
40 except Exception:
41 try:
42 from . import file_cache
43
44 return file_cache.cache
45 except Exception as e:
46 LOGGER.warning(e, exc_info=True)
47 return None
48