本文介绍了在Google App Engine Python中存储值的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很懒!我只想存储一个单一的字符串值。就这样!
我可以跳过任何一种建模并存储一个值吗?

解决方案

取决于您想要的时间长短存储信息,您还可以使用memcache:



导入:

  from google.appengine.api import memcache 

您只需要知道获取和设置数据:

  memcache.set(key,value)
value = memcache.get(key)

如果您的数据需要长期持久性,那么您需要使用后端数据存储。建议您为数据使用memcache和数据存储,因为可以随时刷新memcache。对于短期的,短暂的持久性,memcache可以做到这一点。



更多信息:


I'm lazy! And I just want to store one single string value. That's all!Can I jump over any kind of Modeling and just store a value?

解决方案

Depending on how long you want to store the information, you can also use memcache:

Import:

from google.appengine.api import memcache

All you need to know to get and set data:

memcache.set("key", value)
value = memcache.get("key")

If your data needs long-term persistance, then you need to use the backend datastore. It is recommended to use both memcache and the datastore for your data, since the memcache can be flushed at any time. For short-term, ephemeral persistance, memcache does the trick.

More info here:http://code.google.com/appengine/docs/python/memcache/usingmemcache.html

这篇关于在Google App Engine Python中存储值的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 07:44