开发者

With PHP and AJAX, Can two clients inter-exchange data without MySQL?

开发者 https://www.devze.com 2022-12-23 20:04 出处:网络
Let\'s assume I\'m developing a AJAX, PHP chess game. During the game, one movement of a player will be notified to the a开发者_Python百科nother but we are not saving that information. Normally, we us

Let's assume I'm developing a AJAX, PHP chess game. During the game, one movement of a player will be notified to the a开发者_Python百科nother but we are not saving that information. Normally, we used to store in MySQL every time a player makes movement and show update position to another player. What I want is to reduce MySQL load as much as possible and server is not interested in movements between two players. Server will only save final result like who wins. So what should I do?


I assume you are going to need some sort of persistent storage to save the moves, so the alternative would be a memcache, or storing the data in files. The former is lightning fast but requires to be set up on the server. The latter has no real advantage over using a database IMO.

Any form of storage that takes place only on the users' computers (e.g. storing info in cookies or some other kind of persistent storage, see for example here or here) I would find too shaky: The playing session would be destroyed if both clients would have to restart their computers, which is not totally out of the question to happen.

Without any hard data that the mySQL server is overloaded with this kind of traffic, I would stick with the database. Otherwise, look into memcache.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号