diff options
Diffstat (limited to 'googleapiclient/discovery_cache/appengine_memcache.py')
-rw-r--r-- | googleapiclient/discovery_cache/appengine_memcache.py | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/googleapiclient/discovery_cache/appengine_memcache.py b/googleapiclient/discovery_cache/appengine_memcache.py index 7e43e66ce..1d18d7abb 100644 --- a/googleapiclient/discovery_cache/appengine_memcache.py +++ b/googleapiclient/discovery_cache/appengine_memcache.py @@ -26,30 +26,31 @@ from ..discovery_cache import DISCOVERY_DOC_MAX_AGE LOGGER = logging.getLogger(__name__) -NAMESPACE = 'google-api-client' +NAMESPACE = "google-api-client" class Cache(base.Cache): - """A cache with app engine memcache API.""" + """A cache with app engine memcache API.""" - def __init__(self, max_age): - """Constructor. + def __init__(self, max_age): + """Constructor. Args: max_age: Cache expiration in seconds. """ - self._max_age = max_age - - def get(self, url): - try: - return memcache.get(url, namespace=NAMESPACE) - except Exception as e: - LOGGER.warning(e, exc_info=True) - - def set(self, url, content): - try: - memcache.set(url, content, time=int(self._max_age), namespace=NAMESPACE) - except Exception as e: - LOGGER.warning(e, exc_info=True) + self._max_age = max_age + + def get(self, url): + try: + return memcache.get(url, namespace=NAMESPACE) + except Exception as e: + LOGGER.warning(e, exc_info=True) + + def set(self, url, content): + try: + memcache.set(url, content, time=int(self._max_age), namespace=NAMESPACE) + except Exception as e: + LOGGER.warning(e, exc_info=True) + cache = Cache(max_age=DISCOVERY_DOC_MAX_AGE) |