开发者

Badges system using asynchronous php call

I'd like to implement a badge/reputation system on one of my site. When a user performs an action an event will be raised (ex: QUESTION_PUBLISHED) so that the system can check if a new badge can be awarded to the user.

The logic for some of the badges is quite complex and would require slow sql queries. In开发者_如何学Gostead of using cron jobs I was thinking of using asynchronous calls. So basically I would have:

  1. User performs an action (ex: post a comment)
  2. Event is raised (ex: COMMENT_POSTED)
  3. Badge checks are done asynchronously (CheckJournalistBadge())

Is #3 feasible in PHP?


I don't think asynchronous calls are possible in PHP, but you could sort of simulate. Maybe put the requests in a database and have a cron job that only checks for those requests and marks them as checked or even deletes the rows checked while adding the result (for example if badge is awarded) to the user table (whichever that would be in your case).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜