From 5f385448aaf7917a8c3a8dda23b9923852a08575 Mon Sep 17 00:00:00 2001 From: Peter Siemens Date: Sun, 7 Jan 2024 13:01:22 -0800 Subject: [PATCH] Add comments to AppEngineMemcacheCache --- ubyssey/cache.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ubyssey/cache.py b/ubyssey/cache.py index d407b6756..09889343f 100644 --- a/ubyssey/cache.py +++ b/ubyssey/cache.py @@ -1,6 +1,3 @@ -""" -Django Cache Backend for the Google App Engine Memcache API. -""" import time import logging @@ -9,6 +6,16 @@ from google.appengine.api import memcache class AppEngineMemcacheCache(BaseCache): + """ + Django Cache Backend for the Google App Engine Memcache API. + + This class wraps the Google App Engine Memcache API library, + which is required to make calls to App Engine Memcache from the Python + standard environment. + + This code was adapted from the `django-gae-backends` package: + https://pypi.org/project/django-gae-backends/ + """ def __init__(self, location, params): super(AppEngineMemcacheCache, self).__init__(params) @@ -72,11 +79,11 @@ def set(self, key, value, timeout=None, version=None): key = self.make_key(key, version=version) self.validate_key(key) - # there might be an exception if the pickled data is bigger than 1mb + # There may be an exception if the pickled data is larger than 1MB try: memcache.set(key, value, self._get_memcache_timeout(timeout)) except: - logging.warning('Could not save response in memcache - too large') + logging.warning("Could not save response in memcache - too large") def delete(self, key, version=None): key = self.make_key(key, version=version)