具有消息状态的App Engine消息系统-设计模式

问题描述

| 我正在构建一个线程化消息系统,该系统将托管在Google AppEngine上 我已经按照Brett Slatkin在“在App Engine上构建可扩展的复杂应用程序”中描述的技术进行了建模
class Message(db.Model):
  sender = db.StringProperty()
  body = db.TextProperty()

class MessageIndex(db.Model):
  receivers = db.StringListProperty()
我必须确定最有效的方式来跟踪用户的消息状态的问题。 例如,针对特定用户的消息“ 1”,“ 2”,“ 3”。 这是我到目前为止提出的解决方案。 我正在使用Datastore +的StructuredProperty将状态添加到消息“ 4”中
class Message(model.Model):
  sender = model.StringProperty()
  body = model.TextProperty()

class _DisplayState(model.Model):
  user_key = model.KeyProperty()
  state = model.IntegerProperty(default=0) # 0-unread,1-read,2-archived

class MessageIndex(model.Model):
  receivers = model.StructuredProperty(_DisplayState,repeated=True)
这种解决方案虽然简单,却否定了MessageIndex的优点。另外,由于MessageIndex与消息数据存储区在同一实体组中,因此写入将受到限制。 完整的源代码 什么是实现此目的的最有效方法?添加其他实体组会是更好的解决方案吗?
class MessageState(model.Model):
  user_key = model.KeyProperty()
  message_key = model.KeyPropery()
  message_state = model.IntegerProperty(default=0) # 0-unread,2-archived
    

解决方法

        为了最简单的查询-将\'接收者\'列表分为四个不同的列表-\'未读\',\'读\',\'已存档\',\'已删除\'并将列表之间的接收者记录随机排列为适当。     

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...