B
B
BonBon Slick2017-06-10 23:50:11
Task Schedulers
BonBon Slick, 2017-06-10 23:50:11

Best option for deleting a record when it expires?

The user created a post and chose the date of its deletion, blocking. After which the post will be unavailable / deleted.
The options I'm considering are:
1 - cron command. But I think that the whole thing will be very heavy to load the server, since the command will have to work through all the records every minute. 1,000,000 Posts with the date of deletion, each post has its own time. And it is unlikely that cron will have time to go through all the records, therefore, the timing of some will be violated.
2 - each time a user visits a post page, check to see if his time has expired. It's better to count in minutes, I think, right? Even with the use of Carbon in Laravel, errors are possible. And so write in the columns of the table posts - created_at | delete_after.
The view will look something like thiscreated_at = 2011-01-31 17:22:59, delete_after = 457 (convert save date difference to minutes).
Then, when entering the post, calculate the difference between the date created_at and $current_date in minutes, if more than 457, delete / block the record.
3 - combine . Cron goes through every 3-5 hours in order to clean old records, and additionally do checks when entering the post.
Which option is better, maybe someone has better ideas?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
terrier, 2017-06-11
@BonBonSlick

3rd option, of course.
In any case, you will need logic like "do not show the user records that are deleted." Plus, once every few hours/days/decades (depending on the load), delete (or rather, of course, archive) records.

D
d-stream, 2017-06-11
@d-stream

Option 3 with a minor amendment: kroner + in non-heavy sections of circulation, so that the option of loading 1000 lines does not kick out, where "cleaning" works 1000 times

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question