[英]using php to monitor mysql changes **WITHOUT** polling
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 :
我想知道的是:
Thanks & Regards, Thothathri Srinivasan感谢和问候, Thothathri Srinivasan
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 pubsub实现您的目标。 Redis is an extremely fast data structure server .
Redis 是一个极快的数据结构服务器。 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."下载/安装Redis 非常简单,作为额外的奖励,您还将“获得一个开源的高级键值存储。它通常被称为数据结构服务器,因为键可以包含字符串、散列、列表、集合和排序集合.”
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.安装它可能是最好的方法,但如果你不能,你可以使用免费的http://redistogo.com计划来讨论 Redis 服务器,限制你只能获得 5MB 来存储你的数据,并且它会不会被持久化到磁盘。
您可以将服务器推送与 websockets 或 Comet 之类的实现结合使用。
I like Alfred's pubsub idea.我喜欢阿尔弗雷德的 pubsub 想法。 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.
您还可以监视数据库服务器上的二进制日志以观察更改并将此信息推送给订阅者。
我认为 Q4M 正是你想要的http://q4m.github.com/tutorial.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.