gpt4 book ai didi

javascript - 我如何在 RethinkDB 中取消订阅 'changefeed'?

转载 作者:行者123 更新时间:2023-11-28 00:12:07 25 4
gpt4 key购买 nike

我知道我可以订阅以收听执行此操作的表上的更改

r.table('users').changes().run(conn, function(err, cursor) {
cursor.each(console.log);
});

但是,我怎样才能停下来聆听这些变化呢?我如何取消订阅此更改?

最佳答案

您可以只调用cursor.close(),(或者您可以执行conn.close())

来自docs for cursor.close :

r. Closing a cursor cancels the corresponding query and frees the memory associated with the open request.

此外,关闭连接本身将自动关闭与连接关联的所有游标。换句话说,如果您正确关闭连接,通常不需要显式关闭游标。

来自connection.close docs:

Closing a connection normally waits until all outstanding requests have finished and then frees any open resources associated with the connection. By passing false to the noreply_wait optional argument, the connection will be closed immediately, possibly aborting any outstanding noreply writes.

关于javascript - 我如何在 RethinkDB 中取消订阅 'changefeed'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30790564/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com