使用 php 监控 mysql 更改 **不使用** 轮询

发布于 2024-11-17 13:27:08 字数 349 浏览 5 评论 0原文

我看到很多和我问的问题类似的问题。 其中一些人表示可以轮询,并且不会对数据库性能产生太大影响,还有一些人仍然没有得到答复。我想知道的是:

  • 我可以做一些类似于 ASP.NET 的 sqldependency 的事情,这有助于查明何时对数据库进行了更改不进行轮询。
  • 我知道轮询是可以的,可能不会影响数据库性能,但我需要在更新完成后立即知道更新,所以我觉得我需要比每 1 秒轮询更好的东西。
  • 作为附加点,在服务器上检测到的更新必须推送(Ajax 推送 - 我正在使用 Ajax 推送引擎)到订阅特定频道的所有客户端。

谢谢&问候, 托塔特里·斯里尼瓦桑

I have seen many questions similar to the one I asked.
A few of them said that its ok to poll, and that doesn't affect the database performance significantly, and some are still unanswered. What I want to know is this :

  • Can I do something similar to ASP.NET's sqldependency, which helps to find out when changes are made to the database WITHOUT polling.
  • I know polling is ok to do, might not affect database performance, but I need to know the update as soon as it is made, so I feel I need something better than just polling every 1 second.
  • As an add on point, the updates that are detected at the server then have to be pushed (Ajax Push - I'm using Ajax Push Engine) to all the clients who are subscribed to a particular channel.

Thanks & Regards,
Thothathri Srinivasan

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

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

发布评论

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

评论(4

〆一缕阳光ご 2024-11-24 13:27:08

Redis PubSub

我希望 触发器 可以帮助你,但是之后稍微检查一下我(高度)有我的疑问。

您可以使用 Redis pubsub 来实现您的目标。 Redis 是一个非常快的数据结构服务器。将数据库更改发布到频道,并让感兴趣的客户端通过订阅同一频道(实时)来检测更改。

下载/安装 Redis 非常简单,作为额外奖励,您还将“获得一个开源的、高级的键值对”它通常被称为数据结构服务器,因为键可以包含字符串、散列、列表、集合和排序集合。”

安装它可能是最好的方法,但如果你不能,你可以使用免费的 http://redistogo.com 计划与 Redis 服务器进行对话,但限制是您只能获得 5MB 来存储数据,并且不会将其保存到磁盘上。

Redis PubSub

I hoped triggers could help you out, but after a little examination I (highly) have my doubts.

You could achieve your goal using Redis pubsub. Redis is an extremely fast data structure server. Publish the database changes to a channel and let the interested clients detect the changes by subscribing to that same channel(in real-time).

Downloading/Installing Redis is really easy and as extra bonus you will also "get an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets."

Installing it is probably the best way, but if you can't, you could use the free http://redistogo.com plan to talk the Redis server with the limitation that you will only get 5MB to store your data and that it will not be persisted to disc.

三生池水覆流年 2024-11-24 13:27:08

您可以将服务器推送与 websockets 或 comet 等实现结合使用。

You can use a server push with an implementation like websockets or comet.

余生一个溪 2024-11-24 13:27:08

我喜欢阿尔弗雷德的 pubsub 想法。我会将数据库视为插入事件的订阅者,而不是规范版本。也许这对于您现有的代码库来说是不可能的。您还可以监视数据库服务器上的二进制日志,以观察发生的更改并将此信息推送给订阅者。

I like Alfred's pubsub idea. I would think about the database as a subscriber to the insert events, not as the canonical version. Maybe this isn't possible with your existing codebase. You might also be able to monitor the binary logs on the database server to watch changes come in and push this information to the subscribers.

莳間冲淡了誓言ζ 2024-11-24 13:27:08

我认为 Q4M 正是你想要的
http://q4m.github.com/tutorial.html

I think Q4M is exactly what you want
http://q4m.github.com/tutorial.html

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