Skip to content

Commit

Permalink
Updated memcache error checking to handle large object exception (Goo…
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmats authored and Jon Wayne Parrott committed Jan 6, 2017
1 parent fcdb9ea commit 538078d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion appengine/standard/memcache/guestbook/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# https://developers.google.com/appengine/docs/python/config/appconfig
# for details.

version: 1
runtime: python27
api_version: 1
threadsafe: yes
Expand Down
10 changes: 7 additions & 3 deletions appengine/standard/memcache/guestbook/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ def get_greetings(self, guestbook_name):
greetings = memcache.get('{}:greetings'.format(guestbook_name))
if greetings is None:
greetings = self.render_greetings(guestbook_name)
if not memcache.add('{}:greetings'.format(guestbook_name),
greetings, 10):
logging.error('Memcache set failed.')
try:
added = memcache.add(
'{}:greetings'.format(guestbook_name), greetings, 10)
if not added:
logging.error('Memcache set failed.')
except ValueError:
logging.error('Memcache set failed - data larger than 1MB')
return greetings
# [END check_memcache]

Expand Down

0 comments on commit 538078d

Please sign in to comment.