简体   繁体   English

在Google App Engine上存储常量数据的最佳方法

[英]Best way to store constant data on Google App Engine

I'm making a (quite) simple python web application on GAE. 我正在GAE上制作(相当)简单的python网络应用程序。 The web app basically, ask user input, do basic calculation, then spew out some question from several module based on previous calculation, do basic calculation, spew out more information to the user. Web应用程序基本上是,要求用户输入,进行基本计算,然后根据先前的计算从几个模块中提出一些问题,进行基本计算,向用户输出更多信息。

Now, the problem is 现在的问题是

  • The data that need to be fetched is located throughout the constant data (eg, several small part of the whole data) 需要获取的数据位于整个常量数据中(例如,整个数据的一小部分)
  • The total whole data is about 100kb, required data per user is about 10 kb. 整个数据总量约为100kb,每个用户所需的数据约为10kb。
  • The data is constant, and may be modified (by me). 数据是恒定的,可以(由我自己)修改。
  • I want to conserve cpu cycle. 我想节省CPU周期。 :-) :-)

So far, I've had been hard coding the data in python string literal separated with some if-elif-else as python module, but it is soo ugly (the data is formatted in HTML and more than one line per data). 到目前为止,我一直在用python字符串常量(用一些if-elif-else作为python模块分隔)对数据进行硬编码,但是它太丑陋了(数据以HTML格式格式化,每个数据超过一行)。 I could store it in the database but it may required the more cpu cycle and I don't know an easy way to store constant (non user modifiable) on the datastore. 我可以将其存储在数据库中,但是它可能需要更多的cpu周期,而且我不知道在数据存储区中存储常量(不可用户修改)的简便方法。 Putting it in a file, formatted in XML or something could require even more cpu power on parsing. 将其放在文件中,以XML或其他格式格式化可能需要更多的cpu分析能力。 So what is the best way to store constant data? 那么,存储常量数据的最佳方法是什么?

将数据存储为源代码中的常量,或存储为在应用程序中打开并从中读取相关数据的数据文件。

Ah... whatever. 啊...随便 I use database for that. 我为此使用数据库。 Used cache. 已使用的缓存。 And thinking about denormalizing it even further. 并考虑进一步将其规范化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM