可以在PHP中使用吗

可以在PHP中使用吗

本文介绍了创建Redis侦听器-可以在PHP中使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在业余时间慢慢地学习和学习Redis,我对可用于为订阅频道的网站创建侦听器"并在收到消息时更新网页的选项感兴趣.

I'm slowly digging in and learning redis in my spare time, and I am interested in the options available for creating a 'listener' for a website that subscribes to a channel, and updates a webpage as messages are received.

现在,从我过去的动作脚本时代和当前的javascript工作开始,鉴于这两种语言,我对听众的概念非常熟悉.但是,我的服务器端编程功能实际上仅扩展到PHP,一些rails,一些python和伪node.js(我是一个非常有经验的javascript专家,并且了解node.js的作用).

Now, from my old actionscript days, and current javascript work, i'm quite familiar with the concept of listeners given those two languages. However, my server-side-programming-fu really only extends as far as PHP, a bit of rails, a bit of python, and pseudo node.js (i'm a fairly experienced javascript guy, and understand what node.js does).

由于我的主要技能在于php,所以我想知道是否甚至可以与php进行持久连接/套接字,从而在PHP中创建侦听器?

Since my main skill set lies in php, i'm wondering if it is even possible to do a persistent connection/socket with php and thus create a listener in PHP?

由于我猜想这实际上是不可能的(或者等效于用锤子修复挡风玻璃裂缝),服务器端有哪些选择?是否可以仅创建一个JavaScript侦听器,该侦听器使用与Redis服务器的持久连接(当前在localhost上).我应该研究Socket.io吗?

Since i'm guessing this isn't actually possible (or is the equivalent of fixing a windshield crack with a hammer), what are some server side options? Is it possible to just create a javascript listener that uses a persistent connection to the redis server (currently on localhost). Is Socket.io something I should look into?

任何对Redis初学者的见识将不胜感激.

Any insight for a redis beginner would be much appreciated.

编辑我在部分回答了我的问题.

edit I found a great post here How to use redis PUBLISH/SUBSCRIBE with nodejs to notify clients when data values change? that partially answers my question.

除了node.js之外,还有没有一种方法可以完成相同的工作?我可以完全放弃php并为此项目尝试一些新的东西.无论如何都是个人的.

Is there a method aside from node.js that does the same thing? I'm ok with dropping php completely and trying something new for this project. It's a personal one anyways.

推荐答案

PubSubContext DispatcherLoop 示例是您要在PHP中尝试实现的目标的不同实现.

The PubSubContext and DispatcherLoop examples from the Predis source code on Github are varying implementations of what you are trying to achieve, in PHP.

这篇关于创建Redis侦听器-可以在PHP中使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:56