Package googleapiclient :: Package discovery_cache
[hide private]
[frames] | no frames]

Source Code for Package googleapiclient.discovery_cache

 1  # Copyright 2014 Google Inc. All Rights Reserved. 
 2  # 
 3  # Licensed under the Apache License, Version 2.0 (the "License"); 
 4  # you may not use this file except in compliance with the License. 
 5  # You may obtain a copy of the License at 
 6  # 
 7  #      http://www.apache.org/licenses/LICENSE-2.0 
 8  # 
 9  # Unless required by applicable law or agreed to in writing, software 
10  # distributed under the License is distributed on an "AS IS" BASIS, 
11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
12  # See the License for the specific language governing permissions and 
13  # limitations under the License. 
14   
15  """Caching utility for the discovery document.""" 
16   
17  from __future__ import absolute_import 
18   
19  import logging 
20  import datetime 
21  import os 
22   
23  LOGGER = logging.getLogger(__name__) 
24   
25  DISCOVERY_DOC_MAX_AGE = 60 * 60 * 24  # 1 day 
26   
27   
28 -def autodetect():
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 if 'APPENGINE_RUNTIME' in os.environ: 36 try: 37 from google.appengine.api import memcache 38 from . import appengine_memcache 39 40 return appengine_memcache.cache 41 except Exception: 42 pass 43 try: 44 from . import file_cache 45 46 return file_cache.cache 47 except Exception as e: 48 LOGGER.warning(e, exc_info=True) 49 return None
50