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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里