dongzhan2029 2014-08-04 01:46
浏览 28
已采纳

如何在GAE的数据存储区中存储信息

I would like to store information in the Google Cloud Datastore that is available in GAE.

I have JSON like the following:

{ "users": [
    "ABC123",
    "XYZ987",
    "ZHI663"
    ]
}

I am looking to store this in the data store but can't work out how. I can't use 'Text String' as it's limited to 500 characters and I need to be able to have many users.

I see in the documentation here that there is a 'List' type which sounds exactly like what I need however this option does not show when I am creating an entity in the developers console. See image here:

http://s27.postimg.org/v0x83n89f/entity.png

If you can only use the 'List' type using the API can anyone show me an example of doing this in PHP?

  • 写回答

1条回答 默认 最新

  • douduan5086 2014-08-04 02:24
    关注

    GAE wont lets us modify complex things like List and Text.

    Let me briefly explain, Text or List or Set or Map.

    Text : com.google.appengine.api.datastore.Text

    1. We can store upto 20k characters for a text field.
    2. It wont be indexed.
    3. We cannot modify it in the datastore view.

    List or Set

    1. We can store as many entries into it as we want.
    2. Elements in this will result in complex index i.e. elements will form combination among themselves and hence GAE will index each combination.
    3. We can un-index it by having definition as un-index.
    4. We cannot modify in GAE datastore view.

    Map

    1.Though GAE wont allow Map, we can serialize it and store as blob.   
    2. Limited to 1MB   
    3. We cannot view or modify it in the GAE datastore view.
    

    Of the three, only List or Set is indexed. So if you want to make a query to check whether the json contains the user or not, you should use List or Set.

    If you use other two, you need to fetch it, then check whether the user is there or not.

    All three has its own advantages and disadvantages. So its up to you to decide which one you are going to use for your need.

    If you want to use it while user logs in, then List or Set is the opt one as it can be easily queried because all the entries are pre indexed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测