简体   繁体   English

PHP:如何在不同服务器上的线程之间共享数据?

[英]PHP: How to share data between threads on different servers?

PHP: How to share data between threads on different servers? PHP:如何在不同服务器上的线程之间共享数据?

Suppose server has opened separate threads for each connection. 假设服务器为每个连接打开了单独的线程。

I want to share the data without using database. 我想共享数据而不使用数据库。

Lets say an example: 举个例子:

User1-->Logged in on server1-> Playing a game with x points(server is getting score by AJAX).
User2-->Logged in on server2-> Playing same game with y points(server is getting score by AJAX).

Now i want to make a list of all logged in user with current score(point) of game. 现在,我想列出所有当前游戏得分(点)的登录用户。 How can i do that without using database. 不使用数据库怎么办?

Use a shared memcached server and store the data there. 使用共享的Memcached服务器并将数据存储在该服务器中。

Memcache will act like you would do with a database but much faster, which might be the reason you don't want to use a database here. Memcache的行为类似于您对数据库的处理,但是速度更快,这可能是您不想在此处使用数据库的原因。

您可以使用脚本和CRON作业每分钟传递变量。

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

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