在数据库端实现Comet [英] Implementing Comet on the database-side

查看:105
本文介绍了在数据库端实现Comet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这更多是出于好奇和供将来参考,但是Comet如何在数据库端实现?我知道大多数实现都使用长期存在的HTTP请求来等待直到数据可用,但是如何在服务器端完成呢? Web服务器如何知道何时有新数据可用?它会不断轮询数据库吗?

This is more out of curiosity and "for future reference" than anything, but how is Comet implemented on the database-side? I know most implementations use long-lived HTTP requests to "wait" until data is available, but how is this done on the server-side? How does the web server know when new data is available? Does it constantly poll the database?

推荐答案

您正在使用什么数据库?如果它支持触发器(许多RDBMS都采用某种形式),那么触发器可以触发一个事件,该事件实际上告诉HTTP请求发出适当的响应。

What DB are you using? If it supports triggers, which many RDBMSs do in some shape or form, then you could have the trigger fire an event that actually tells the HTTP request to send out the appropriate response.

触发器不再需要轮询...轮询通常不是最好的主意。

Triggers remove the need to poll... polling is generally not the best idea.

PostgreSQL 似乎有很好的支持(甚至PL / Python)。

PostgreSQL seems to have pretty good support (even PL/Python).

这篇关于在数据库端实现Comet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆