谷歌应用程序引擎持久性全局 [英] google app engine persistent globals

查看:102
本文介绍了谷歌应用程序引擎持久性全局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来保持app引擎(python)中持久的全局变量的等价性。我在做的是创建一个全局类型,我初始化一次(即当我测试时重置所有数据库对象)。我有像全球计数器那样的东西,或者是下一个ID来分配我创建的某些种类。

I'm looking for a way to keep the equivalent of persistent global variables in app engine (python). What I'm doing is creating a global kind that I initialize once (i.e. when I reset all my database objects when I'm testing). I have things in there like global counters, or the next id to assign certain kinds I create.

这是一种体面的方式来做这种事情,或者是普遍存在的另一种方法是使用?

Is this a decent way to do this sort of thing or is there generally another approach that is used?

推荐答案

数据存储是唯一可以保证 数据也是可以修改的。因此,您可以拥有一个大对象或多个较小的对象(具有name属性和其他属性),具体取决于您所需的访问模式 - 但必须位于数据存储中。您可以使用 memcache 来获得更快的缓存,通常 存在于所有查询中,但任何memcache条目都可能随时消失,所以您始终需要它由数据存储支持(特别是,任何更改都必须到达数据存储区,而不是 到memcache)。

The datastore is the only place you can have guaranteed-persistent data that are also modifiable. So you can have a single large object, or several smaller ones (with a name attribute and others), depending on your desired access patterns -- but live in the datastore it must. You can use memcache for faster cache that usually persists across queries, but any memcache entry could go away any time, so you'll always need it to be backed by the datastore (in particular, any change must go to the datastore, not just to memcache).

这篇关于谷歌应用程序引擎持久性全局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆