简体   繁体   English

在Node和PHP之间与Redis进行会话共享

[英]Session sharing with Redis between Node and PHP

I have a web app running in PHP over CakePHP framework in IIS on a Windows 2008 server machine. 我有一个Web应用程序,它在Windows 2008服务器计算机上的IIS中的CakePHP框架上的PHP中运行。

Now, this application is polling every 6 seconds per connected user to refresh part of the screen and this is causing tends of requests to the IIS server and slowing the whole system down when the Oracle database is busy. 现在,该应用程序每6秒钟对每个已连接的用户进行轮询以刷新屏幕的一部分,这导致向IIS服务器发送请求的趋势,并在Oracle数据库繁忙时降低了整个系统的运行速度。

In an attempt to solve this issue I'm thinking of using Node.js to solve this problem and using push notifications. 为了解决此问题,我正在考虑使用Node.js解决此问题并使用推送通知。 This way every 6 seconds Node would push notifications to all active browser clients. 这样,每隔6秒,Node会将通知推送到所有活动的浏览器客户端。

The problem I'm facing is that the call I'm making is making use of the logged user session. 我面临的问题是我进行的呼叫正在使用记录的用户会话。 (to call the DB, and once I get the data, to update the session). (以调用数据库,并在获取数据后更新会话)。

I've read Redis can be a solution for this and I've seen posts explaining how to share the session . 我已经阅读过Redis可以解决此问题,并且看到过一些帖子解释了如何共享会议 But there's something I don't get yet: 但是有一些我还没有得到的东西:

How could I have the session of the logged user? 我如何拥有已登录用户的会话? Should I iterate over all active sessions? 我应该遍历所有活动的会话吗?

I want to create a setInterval in node to query the DB for each logged user. 我想在节点中创建一个setInterval来为每个登录用户查询数据库。

I can understand you issue i implemented a similar kind of structure for web chat . 我能理解您的问题,我为网络聊天实现了类似的结构。 With redis or memcache you can create you own data structure to hold users session it will be loaded into ram ,really fast and it will work like global session will be accessible to all users session and for any node or ajax request from browser you will access redis and return response back to user rather than sending request to Oracle database and than back to user . 使用redis或memcache,您可以创建自己的数据结构来保存用户会话,它会非常快地加载到ram中,并且就像所有用户会话都可以访问全局会话一样,并且您可以访问来自浏览器的任何节点或ajax请求重做,并将响应返回给用户,而不是将请求发送到Oracle数据库然后再返回给用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM