1   
 2   
 3   
 4   
 5   
 6   
 7   
 8   
 9   
10   
11   
12   
13   
14   
15  """App Engine memcache based cache for the discovery document.""" 
16   
17  import logging 
18   
19   
20   
21  from google.appengine.api import memcache 
22   
23  from . import base 
24  from ..discovery_cache import DISCOVERY_DOC_MAX_AGE 
25   
26   
27  LOGGER = logging.getLogger(__name__) 
28   
29  NAMESPACE = "google-api-client" 
30   
31   
33      """A cache with app engine memcache API.""" 
34   
36          """Constructor. 
37   
38        Args: 
39          max_age: Cache expiration in seconds. 
40        """ 
41          self._max_age = max_age 
 42   
44          try: 
45              return memcache.get(url, namespace=NAMESPACE) 
46          except Exception as e: 
47              LOGGER.warning(e, exc_info=True) 
 48   
49 -    def set(self, url, content): 
 50          try: 
51              memcache.set(url, content, time=int(self._max_age), namespace=NAMESPACE) 
52          except Exception as e: 
53              LOGGER.warning(e, exc_info=True) 
  54   
55   
56  cache = Cache(max_age=DISCOVERY_DOC_MAX_AGE) 
57