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 return appengine_memcache.cache
39 except Exception:
40 try:
41 from . import file_cache
42 return file_cache.cache
43 except Exception as e:
44 LOGGER.warning(e, exc_info=True)
45 return None
46