Skip to content

Commit

Permalink
Add comments to AppEngineMemcacheCache
Browse files Browse the repository at this point in the history
  • Loading branch information
psiemens committed Jan 7, 2024
1 parent 2c66783 commit 5f38544
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ubyssey/cache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
"""
Django Cache Backend for the Google App Engine Memcache API.
"""
import time
import logging

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5f38544

Please sign in to comment.