PHP forums - how to cope with unread discussions / topics / posts

后端 未结 7 1049
伪装坚强ぢ
伪装坚强ぢ 2020-12-07 17:10

I know this question has been asked here a couple of times, but none of the answers had pleased me. This is because almost all of them involve a huge read / write process re

7条回答
  •  半阙折子戏
    2020-12-07 17:22

    There isn't a lot of choices.

    1. mark every reader thread by each user.

      • Disadvantages: a lot of rows in very active forums
      • Advantages: Every user knows with post has read or not.
    2. mark every unread thread by each user.

      • Disadvantages: a lot of space with "unreaded" rows if there is inactivity of a lot of users
      • Solutions: add a lifetime timestamp and delete old records with a cron
      • Advantages: Every user knows with post has read or not.
    3. use timestamps to determine if show it as unread or not.

      • Disadvantages: The users don't know with are the real unread threads, the marks only show the "new trheads" since the last login
      • Advantage: Save space

    The other alternative is mixing solutions, that is,

    1 and 3) show thread as "unread" if they aren't older than X days and there isn't a row marked as readed for the user. The "read" rows can be deleted when they are X day older without affect anything.

    Advantages

    • less spaced used to determine unread threads

    Disadvantages

    • create a cron that keeps the system clean
    • Users don't know if they read threads olders than x days.

    Advantages

    • Every user knows which "new posts" has read or not.

提交回复
热议问题