【问题标题】:How to emulate a streaming API?如何模拟流式 API?
【发布时间】:2012-04-15 15:17:40
【问题描述】:

我需要维护对 API 的几乎实时访问(以便在 API 响应发生更改时立即通知程序)。提供的 API 是非实时的。我想要的是类似于 Twitter 的流 API(https://dev.twitter.com/docs/streaming-api)的东西。

我可以每秒发送一次 API 调用,但这太低效了。有什么更好的方法来做到这一点?我可能会在 Python 或 Node.js 中执行此操作。

【问题讨论】:

标签: python api node.js real-time


【解决方案1】:

由于您是客户端,除了每隔几秒轮询一次 API 之外,您完全无法知道 API 响应是否发生变化。

通过使用保证没有更改的最短时间或在不知道更改时可以承受的最长时间来减少 API 调用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-23
    • 2017-11-09
    • 2011-09-17
    • 2016-01-13
    • 1970-01-01
    • 2011-08-11
    • 2019-01-20
    • 2023-03-30
    相关资源
    最近更新 更多