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 NAMESPACE = 'google-api-client'
27
28
30 """A cache with app engine memcache API."""
31
33 """Constructor.
34
35 Args:
36 max_age: Cache expiration in seconds.
37 """
38 self._max_age = max_age
39
41 try:
42 return memcache.get(url, namespace=NAMESPACE)
43 except Exception as e:
44 logging.warning(e, exc_info=True)
45
46 - def set(self, url, content):
47 try:
48 memcache.set(url, content, time=int(self._max_age), namespace=NAMESPACE)
49 except Exception as e:
50 logging.warning(e, exc_info=True)
51
52 cache = Cache(max_age=DISCOVERY_DOC_MAX_AGE)
53