开发者

Forum unread post implementation

开发者 https://www.devze.com 2023-03-01 15:38 出处:网络
Asp.net mvc3 forum implementation. Part of the implementation is a feature that shows what posts have been read an what posts have not.

Asp.net mvc3 forum implementation. Part of the implementation is a feature that shows what posts have been read an what posts have not.

The way I开发者_Python百科 have implemented it now is that I create an entry in my data for each user at creation of a new post, and then remove them as they are displayed to my users,I also delete all under entries older then 1 month.

I currently have 450 users, so it takes quit a long time to create them all.

I was thinking there must be a better way as large vbullitin or phpbb forums with more then 1000 users can do this without spending 2+ sek at post creation, to create all these entries, but I have not found it. I can see there some other questions about this on this site, but I have not found an answer I can use.


You need to record user's last activity but storing everything in the database will not be efficient. Due to that, you'll also need to set cookies to know what threads they viewed. A bit of a hybrid approach but there are some lengthily discussions about it here:

  • Handling unread posts in PHP / MySQL
  • How to show unread/read status of forum post's like vbulletin, phpbb, others?
  • PHP forums - how to cope with unread discussions / topics / posts


One way to store less data and make things run faster: For each thread that a user reads, create a database entry to log the timestamp when they last viewed that thread. This way each user doesn't get an entry for every post - just per-thread... and only for threads they actually read.

You can easily then determine what within a thread is unread... if you have no timestamp in the DB for this user/thread, then it's all unread for them. If you have a timestamp, all posts in the thread after that timestamp are unread.


Maybe each user should hold on to the IDs of the posts they have viewed rather than those that they have not viewed? It's going to be considerably less costly at the point of creation.

0

精彩评论

暂无评论...
验证码 换一张
取 消