def get_greetings(self, guestbook_name):
"""
get_greetings()
Checks the cache to see if there are cached greetings.
If not, call render_greetings and set the cache
Args:
guestbook_name: Guestbook entity group key (string).
Returns:
A string of HTML containing greetings.
"""
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.')
return greetings
# [END check_memcache]
# [START query_datastore]
评论列表
文章目录