How can I detect redundant rows in the table?

前端 未结 4 1091
梦谈多话
梦谈多话 2020-12-22 12:19

I\'m following solution #1 of this answer. After a while, there will be some redundant rows in the table. Suppose this table:

+------+------         


        
4条回答
  •  不思量自难忘°
    2020-12-22 12:50

    Add another column with a timestamp. Then run a regular cron job to delete any rows with a timestamp older than a certain threshold (say, 1 day for instance).

    You can either put in a timestamp and update it every time you see that user, which means they get "logged out" x amount of time after they last used the site (but that means more database transfer); or you can just put in a timestamp when you create the session the first time and never touch it again, which will "log them out" x amount of time after they last logged in (less convenient for the user perhaps, but it means less database transfer).

提交回复
热议问题