删除未订阅的订阅
- Laravel6
- Lighthouse-PHP5
我正在使用Lighthouse-PHP进行GraphQL订阅,并且我收到了Pusher的消息。
因此,我有订阅的问题取消订阅。
服务器端=> pusher =>前侧
文档此部分意味着只停止 pusher =>前侧。 如果我不删除redis,仍然可以使用服务器端并将消息推向推动器,对吗?
unsubscribeFromChannel(subscriptionChannel) {
this.pusher.unsubscribe(subscriptionChannel);
}
我想停止服务器sine =>推动器也。 我有什么选择?
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是在灯塔文档中记录的,此处的直接链接:。
但是,这里的一些片段以防万一。
因此,设置此
.env
变量是一种过期订阅的好方法,这些订阅会自动留在后面,如果您每小时有很多长期运行的订阅,则设置足够大的时间。但是,由于您使用的是Pusher,因此有一种更快的方法来清理订阅:
此Webhook(频道存在Webhook作为Pusher称为它们)将删除已腾空的通道(没有剩余的订户)的订阅,这将发生在用户断开连接将订阅保持在Redis中的几秒钟。
这么长的故事简短,为订阅设置了TTL作为后备,并为您的应用程序配置了Pusher Webhook。这将使订阅保持最新状态并防止不需要的工作。
This is documented in the Lighthouse documentation, a direct link here: https://lighthouse-php.com/5/subscriptions/getting-started.html#expiring-subscriptions.
But also some snippets here just in case it helps.
So setting this
.env
variable is a great way to expire subscriptions that are left behind automatically, do set this timeout large enough, if you have a lot of long running subscriptions an hour might not be enough.But since you are using Pusher there is a faster way to cleanup the subscriptions:
This webhook (channel existence webhook as Pusher calls them) will remove subscriptions for channels that are vacated (no subscribers left) this will happen a few seconds after the user disconnects keeping the subscriptions in Redis up-to-date.
So long story short, setup a TTL for the subscriptions as a fallback and configure the Pusher webhook for your app. This will keep the subscriptions stored up-to-date and prevent unneeded work.