我正在使用带有 python 的谷歌应用引擎,我刚刚实现了 memcache,在用户端一切看起来都很好。数据被正确缓存,但是当我查看日志时,我看到每次打开页面时都会弹出随机错误代码。现在,无论我打开多少次,单个页面的它们都是相同的,它只存储在 memcache 中一次,但每次都会出现两个错误代码。第一个总是-1,第二个是随机的。一些例子是 194、214、204、77、208 和 158。除了时间之外没有更多信息。
这是我正在执行实际缓存的代码,每次用户在我的网站上发布新帖子时都会发生这种情况:
class PostPage(BlogHandler):
def get(self, post_id, subject):
key = db.Key.from_path('Post', int(post_id), parent=blog_key())
key = str(key)
post = memcache.get(key)
if post is None:
logging.error('DB QUERY')
post = db.get(key)
memcache.set(key, post)
if not post:
self.error(404)
return
self.render("permalink.html", post = post)
知道是什么原因造成的吗?是我要求获取 Key.from_path 吗?
这是实际的日志:
2012-07-02 22:52:21.331 /post/31001/profile-pages-down-for-maintenance 200 47ms 2kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
E 2012-07-02 22:52:21.318 DB QUERY
E 2012-07-02 22:52:21.330 -1
E 2012-07-02 22:52:21.330 208
2012-07-02 22:52:18.311 /js/bootstrap.js 404 35ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
2012-07-02 22:52:17.910 / 200 115ms 4kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
2012-07-02 22:52:14.797 /js/bootstrap.js 404 34ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
2012-07-02 22:52:14.499 /profile/17001 200 90ms 3kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
2012-07-02 22:52:14.173 /profile 302 104ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
2012-07-02 22:52:13.198 /js/bootstrap.js 404 36ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
2012-07-02 22:52:12.823 / 200 138ms 4kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
2012-07-02 22:51:59.664 /search?q=paragliding 200 35ms 2kb Mediapartners-Google
2012-07-02 22:51:57.902 /static/bootstrap.css 200 32ms 0kb
2012-07-02 22:51:57.860 /js/bootstrap.js 404 30ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
2012-07-02 22:51:57.537 /search?q=paragliding 200 57ms 2kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
2012-07-02 22:51:51.105 /js/bootstrap.js 404 30ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
2012-07-02 22:51:50.838 / 200 119ms 4kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
2012-07-02 22:50:49.812 /favicon.ico 404 96ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
2012-07-02 22:48:43.633 /post/14009/more-fantastic-paragliding 200 1090ms 2kb Mediapartners-Google
E 2012-07-02 22:48:43.632 137
E 2012-07-02 22:48:43.632 365
2012-07-02 22:48:42.464 /robots.txt 404 29ms 0kb Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
2012-07-02 22:48:41.513 /js/bootstrap.js 404 31ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
2012-07-02 22:48:41.288 /post/14009/more-fantastic-paragliding 200 48ms 2kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
E 2012-07-02 22:48:41.287 137
E 2012-07-02 22:48:41.287 365