将 PHP 与 Orbited 连接起来

发布于 2024-08-15 16:43:16 字数 422 浏览 9 评论 0 原文

在网上搜索了一个好的 Comet 并询问你们我的最好的选择是,我选择使用 Orbited。问题是,如果您需要有关 Comet 的良好文档,您将找不到。我已经安装了 Orbited,看起来它工作得很好。

基本上,我想不断检查数据库并查看是否有新数据。如果有的话,我想将其推送给我的客户并更新他们的主页,但我找不到任何好的、清晰的文档来解释如何不断检查数据库并将新信息推送到 Orbited,然后推送给客户。你们实施了吗?

另外,Orbited 可以处理多少用户?

有什么想法吗?

After searching the web for a good Comet and also and asking you guys what my best option is, I've chose to go with Orbited. The problem is if you need a good documentation about Comet you won't find. I've installed Orbited and It seems It works just fine.

Basically, I want to constantly check a database and see if there is a new data. If there is, I want to push it to my clients and update their home page but I can't find any good and clear doc explaining how constantly check the database and push the new info to Orbited and then to the clients. Have you guys implemented that?

Also, how many users can Orbited handle?

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

叫嚣ゝ 2024-08-22 16:43:16

您可以添加一个数据库触发器,当数据库发生更改时,它会向您的消息队列发送消息。 此处也建议。或者,如果只是您的应用程序与数据库通信,您可以通过 Subject/Observer 模式,每当有人调用某个操作更改某些内容时通知队列在数据库中。

我不知道轨道天平的好坏。

You could add a database trigger that sends messages to your message queue when the database got changed. This is also suggested here. Or, if it is only your app talking to the database, you could handle this from within the app via a Subject/Observer pattern, notifying the queue whenever someone called an action changing something in the DB.

I don't know how good or bad Orbited scales.

第几種人 2024-08-22 16:43:16

有一个参考表来跟踪源表的上次更新时间。为源表创建一个更新/删除/插入触发器,用于更新引用表中的时间。

您的彗星脚本应不断检查参考表以了解时间的任何变化。如果发现更改,您可以读取更新的源表并将数据推送到客户的主页。在循环中检查引用表会更快,因为如果没有任何更改,MySQL 将从其缓存中提供结果。

抱歉,我对 Orbited 不太了解。

Have a reference table that keeps track of the last updated time of the source table. Create a update/delete/insert trigger for the source table that updates the time in the reference table.

Your comet script should keep checking the reference table for any change in the time. If the change is noticed, you can read the updated source table and push the data to your client's home page. Checking the reference table in a loop is faster because the MySQL will serve the results from its cache if nothing has changed.

And sorry, I don't know much about Orbited.

各空 2024-08-22 16:43:16

我将使用 STOMP 协议与 Orbited 进行通信并将数据推送到客户端。只需找到一个好的 PHP STOMP 客户端即可开始。

以下是 STOMP 的用例示例,尽管服务器端是用 Ruby 编写的:
http://fuglyatblogging.wordpress.com/2008/10/

我不知道如果 PHP 与 Apache(如果您正在使用的话)是监视数据库更改的最佳套件。请阅读标题为“Orbited Server”的这篇文章,了解解释:http://thingsilearned.com/2009/06/09/starting-out-with-comet-orbited-part-1/

编辑:如果你想走这条路线通过 Web 服务器使用 PHP,您需要向脚本发出一个且仅一个请求,以启动监视并推送更改。如果该脚本超时或失败,您需要启动一个新脚本。有点丑陋:) 一种更好、更干净的方法是,例如,使用twisted 和 python 来启动监控进程,与网络服务器完全分离。

I would use the STOMP protocol with Orbited to communicate and push data to clients. Just find a good STOMP client with PHP and get started.

Here is an example of a use case with STOMP, although the server side is written in Ruby:
http://fuglyatblogging.wordpress.com/2008/10/

I don't know if PHP with Apache (if that's what you are using) is the best suite for monitoring database changes. Read this article, under the section title "Orbited Server", for an explanation: http://thingsilearned.com/2009/06/09/starting-out-with-comet-orbited-part-1/

EDIT: If you want to go the route with PHP through a web server, you need to make one, and one only, request to a script that starts the monitoring and pushes out changes. And if that script times out or fails, you need to start a new one. A bit fugly :) A nicer, cleaner way would be, for example, to use twisted with python to start a monitoring process, completely separated from the web-server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文