在数据库端实现Comet

编程入门 行业动态 更新时间:2024-10-27 00:23:28
本文介绍了在数据库端实现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

本文发布于:2023-10-18 12:25:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504228.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   Comet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!