douji7399 2013-11-10 15:03
浏览 38
已采纳

一个小的PHP脚本(需要逻辑帮助)

I am a .net developer and devolving an application for a company. For that I need to write a little php script to meet my needs. My app need to check some information which randomly change almost every second from internet. I am thinking to make a php script so that I can give app the needed information. My idea is to use a simple text file instead of a mysql database (I am free to use a mysql db also). And then make two php pages. For example writer.php and reader.php

work of writer.php is very simple. This file will save the submitted data to the text file I want to use as db.

reader.php will read the text file and then show as simple text and on every read it will also empty the text file.This file will be read by my app. work done.

Now the logical questions.

  • reader.php will be read by 40 clients in the same time. If there is any conflicts?

  • If this method will be fast than mysql db?

  • If this method is more resource consuming than a mysql db?

  • 写回答

1条回答 默认 最新

  • dsi37923 2013-11-10 15:08
    关注

    You will have to lock the file for I/O for the time of writting (PHP flock() function). This may slow down things a bit when there will be more clients at same time, as when file will be locked by one user, everyone else would have to wait. The other problem that may appear when writting alot o data is that writting queue may become infinite when there would be many write requests.

    MySQL seems to be better idea, as it caches both write and read requests, and it is implemented to avoid simultanous access conflicts.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序