具有消息状态的App Engine消息系统 - 设计模式 [英] App Engine Messaging System with Message Status - Design Pattern
问题描述
我正在构建一个将在Google AppEngine上托管的Threaded Messaging系统
我已经使用Brett Slatkin描述的技术对在App Engine上构建可扩展的复杂应用程序
class Message(db.Model):
sender = db.StringProperty()
body = db.TextProperty()
class MessageIndex(db.Model):
receivers = db.StringListProperty()
我不得不确定跟踪用户消息状态的最有效方法。 以下是我到目前为止所提出的解决方案。 我使用 Datastore + 的StructuredProperty将状态添加到消息 这个解决方案虽然简单,却否定了MessageIndex的好处。此外,由于MessageIndex与消息数据存储的写入限制在同一个实体组中。 完成此操作最有效的方法是什么?添加额外的实体组是一个更好的解决方案吗? I'm building a Threaded Messaging System that will be hosted on Google AppEngine I've modeled it after the technique described by Brett Slatkin in Building Scalable, Complex Apps on App Engine The issue I'm having to determining the most efficient way to track the message state for a User.
For example is a message Here are the solution I have come up with so far. I'm using Datastore+'s StructuredProperty to add a state to the message This solution, while simple, negates the benefit of the MessageIndex. Additionally since the the MessageIndex is in the same entity group as the message datastore writes will be limited. What would be the most efficient way to accomplish this? Would adding an additional entity group be a better solution?
For the easiest querying - split your 'receivers' list into four different lists - 'unread', 'read', 'archived', 'deleted' and shuffle the receiver record between the lists as appropriate. 这篇关于具有消息状态的App Engine消息系统 - 设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
例如,一条消息读取
,存档
,已删除$ c
MessageIndex
class Message(model.Model):
sender = model.StringProperty()
body = model.TextProperty()
$ b $ class _DisplayState(model.Model):
user_key = model.KeyProperty()
state = model.IntegerProperty(default = 0)#0-未读,1-read,2-archived
$ b $ class MessageIndex(model.Model):
receivers = model.StructuredProperty(_DisplayState,repeated =真)
class MessageState(model.Model):
user_key = model .KeyProperty()
message_key = model.KeyPropery()
message_state = model.IntegerProperty(default = 0)#0 - 未读,1读,2 - 归档
$ c $对于最简单的查询 - 将你的'接收者'列表分成四个不同的列表 - '未读','','','','','',''。 '读','存档','删除',并在适当的时候在列表之间洗刷接收者记录。 class Message(db.Model):
sender = db.StringProperty()
body = db.TextProperty()
class MessageIndex(db.Model):
receivers = db.StringListProperty()
read
, archived
, deleted
for a particular user.MessageIndex
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)
class MessageState(model.Model):
user_key = model.KeyProperty()
message_key = model.KeyPropery()
message_state = model.IntegerProperty(default=0) # 0-unread, 1-read, 2-archived