-2

My 1st post, but i got many great answers and tips from stackoverflow so far. This one was a close call-> How does facebook, gmail send the real time notification? but not exactly, so let brainstorm this together.

I have CMS system with mail notification when a change is made on the site. Everything wotk very well but i want to prevent multiple notification if somene make another quick change to, let say, fix a typo. Using php mail(), obviously.

I've tough of 2 ways, one simple, and one.... let just say, pretty heavy... cough. the 3rd one was inspired by Implementing Email Notification but really doesn't look appealing to me to send bunch of email at once.

  1. Use a timestamp to check if another change was made in the 'let say' last 5 minutes.

  2. Record the last change, and compare it to the new one. Could be usefull for backup at the same time since i'll have to save the change somewhere, but text can be long and making an sql search would be painfull. Wouldn't it?

  3. Use cron to send changes every x minutes... convince me if you ythink it is a suitable solution.

Any ideas, comment or suggestion of your own? Looking forward for your inputs, and since i now registered, i'll do my best to help around.

Cheers, all llt

Community
  • 1
  • 1

1 Answers1

0

About the cron job, that is always a good alternative since removes part of the burden in the php processing to check timings, DB, extra files etc. But only makes sense if you really have a use for it, for instance, if you have 10 users, that may be overkill. If you have 1000 then you just have to optimize the process of the mailing itself, but is still a great option.

About timestamp, checking the database constantly in search of changes is time consuming for the system and overloads the DB. unless you have a table dedicated to that, only to changes in posts, then there is not much work for the system, plus you can clean the obsolete records every few times that you use the info.

Recording the last change of the post itself and comparing to a new/old version constantly could be overwhelming to the system if you have many users.

So, I'll use a table dedicated to changes in posts where I'll have something like id_post, timestamp_of_the_change and mail_sent. Then after any update to that table, I'll check if the post has been modified in the last minute or so and if that happened, I'll update the timestamp but wont be sending a new mail, unless the last process of sending the mail failed, that's what I'll use the third field there.

Bye

PatomaS
  • 1,603
  • 18
  • 25