记住多个项目的已读/未读状态的最有效方法是什么?
例如,我们采用论坛的格式,其中有多个用户和多个线程。 假设该论坛想要跟踪哪些用户已阅读哪些线程,并在查看线程列表时使用该信息来标记哪些线程未读。
我能想到的唯一解决方案是每次用户访问线程时将记录放入数据库中。 我想可能有一个“将所有标记为已读”按钮,它可以使用时间戳来帮助减少数据库中的蔓延......不管这不是一个让我印象深刻的解决方案。
我有一种感觉,我在这里错过了一些东西......也许感恩节早上不是思考编程问题的时间。
对此有更好的解决方案吗? 有任何想法吗?
For example, let's take the format of a forum, where we have multiple users and multiple threads. Say this forum wants to track which users have read which threads and, say, use that information to mark which threads are unread when viewing the thread list.
The only solution I can imagine is something that drops a record into the database each time a user visits a thread. I suppose there could be a 'mark all as read' button, which could employ a time stamp to help lessen the sprawl in the database... regardless this isn't a solution that impresses me.
I have a feeling that I'm missing something here... maybe Thanksgiving morning isn't the time to think over one's programming problems.
Is there a better solution out there for this? Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用数据库记录对我来说听起来是最有希望的。 如果您有一个活跃的论坛,它将很快生成一个包含数百万行的表,但这将是最简单的实施解决方案。 它将为查询哪些用户正在阅读什么内容提供很大的灵活性。
Using a database record sounds like the most promising to me. It will generate a table with millions of rows very quickly if you have an active forum but it would be the simplest solution to implement. It will give a lot of flexibility for querying which users are reading what too.
我想我在某个地方看到过,也许是 phpbb 论坛? 无论如何,
其中有一个表,其中包含 userid、threadid、last-read-datetime(将其命名为 userAsRead),
然后它将比较该 threadid 中发布的最后一篇文章与最后读取的日期时间,
以将标记标记为全部已读,这是一个使用与上面相同的逻辑的用户表中的字段
不要忘记清除 userAsRead 如果使用“标记为全部读取”,将节省数据库空间
I think I saw somewhere, maybe phpbb forum? anyway
there was a table in it with userid, threadid, last-read-datetime (let name it userAsRead)
then it would compare the last post made in that threadid vs last-read-datetime
for the mark as all read, it was a field in the usertable using the same logic as above
don't forget to clear the userAsRead if "mark as all read" is used, would save DB space