How do I prevent AppEngine memcache flushes

2019-08-04 07:21发布

We are currently using AppEngine's memcache to store session information (session tokens) and to cache some HTML data. Our overall memcache usage is below 1 MB most of the time.

How do we prevent the cache to flush after a few minutes (this morning we had a after 40 minutes with only 25 KB). Yesterday (2013-10-15 21:30 UTC - 2013-10-15 21:45) we had flushes sometime within 2 to 7 seconds (with below 20 KB of data)?

2条回答
你好瞎i
2楼-- · 2019-08-04 07:53

With the default free memcache your apps memcache data is stored along with that of other AppEngine apps, and so if the other apps cause the available memory to fill up then your data is just as likely to be expired as theirs is (see https://developers.google.com/appengine/docs/adminconsole/memcache). Therefore your application should not expect a cached value to always be available.

You can however configure your app to use Dedicated memcache (in the admin console, under Application Settings). This dedicates specific memory for your apps use only but comes at a cost of $0.12 per GB per hour.

查看更多
疯言疯语
3楼-- · 2019-08-04 08:09

you should try to store this data persistently on datastore and use memcache to get the query result or set it if not in memcache. I have read a lot about 'forcing' memcache to perform differently than it has been designed for, but it remains the fact that you cannot never been 100% certain that you will find the data there when you ask for a get.

All the session handlers I tried provide tokens storage into a User model, for example. You can extend this model or create another one to store HTML.

Check out here for use of @webapp2.cached_property also

查看更多
登录 后发表回答