Is there any way to push the data onto the web as soon as some data are updated into the DB instead of polling do we have some events which can check whenever some data is updated into the DB. I am dealing with some 5,60,000 records on DB so whenever any stock data gets changed i have to push a message onto the web.

一旦将一些数据更新到数据库而不是轮询,有没有办法将数据推送到Web上我们是否有一些事件可以检查何时某些数据更新到数据库中。我正在处理关于数据库的大约5,60,000条记录,因此每当任何股票数据发生变化时,我都必须将消息发送到网上。

So i have been told to do it with Node.js. I tried it but it was a kind of long polling in which i have to set the time and after that period it will continuously hit the db and fetch the updated data. Is there other way to do it instead of polling like a kind of some update event.

所以我被告知要用Node.js来做。我尝试了它,但它是一种长轮询,我必须设置时间,在那段时间后,它将持续点击数据库并获取更新的数据。有没有其他方法来做它而不是像一种更新事件一样轮询。

1 个解决方案

#1


1

To achieve what you want there are two problems you should solve :

要实现您想要的目标,您应该解决两个问题:

  1. The connexion Node <=> Database
  2. 连接节点<=>数据库

  3. The connexion Node <=> Webpage
  4. 连接节点<=>网页

The first problem depends on the database you are using. For example if you are using Postgres you should check http://bjorngylling.com/2011-04-13/postgres-listen-notify-with-node-js.html or in the case of mongoDB you should check https://github.com/TorchlightSoftware/mongo-watch There are probably similar solutions for other databases as well.

第一个问题取决于您使用的数据库。例如,如果您使用的是Postgres,则应查看http://bjorngylling.com/2011-04-13/postgres-listen-notify-with-node-js.html,或者对于mongoDB,您应该检查https:// github.com/TorchlightSoftware/mongo-watch其他数据库也可能有类似的解决方案。

The second problem is what NodeJS does best : a seamless connexion between the webpage and the server is easily achieved using SocketIO : http://socket.io/ which allows Node to send update events with the new data to to your webpage, without the hassle of long polling.

第二个问题是NodeJS最擅长的:使用SocketIO可以轻松实现网页和服务器之间的无缝连接:http://socket.io/允许Node将带有新数据的更新事件发送到您的网页,而无需长期民意调查的麻烦。

更多相关文章

  1. 使用Directive通过AngularJS使用指令和数据绑定来注入HTML
  2. ng- repeat显示的行等于no属性,甚至不显示html视图上的数据
  3. 将数据从AJAX请求序列化到PHP
  4. 在Servlet和HTML页面之间处理函数调用和数据传输的最佳方法是什
  5. 访问D3的var格式数据
  6. HTML/JS作为本地SQLite数据库的接口
  7. 如何使用条件if()使用javascript检索带有指定值的选择标记的xml数
  8. 使用Object.observe 实现数据绑定
  9. 环回 - 在“保存后”挂钩中覆盖之前查看数据

随机推荐

  1. 使用wamp扩展php时出现服务未启动的解决
  2. PHP中的C#类扩展方法?
  3. yii框架给我们所带来的好处?
  4. 工具mantisbt--将mantis安装到已经搭建好
  5. [微信支付] 服务端PHP开发纪要
  6. php变量函数,回调函数
  7. PHP里为啥会有session_start()这个函数?
  8. 使用phpnow本地搭建Discuz!如何实现伪静
  9. 使用JOIN获取有关两个用户的信息
  10. Yii 访问 Gii(脚手架)时出现 403 错误