duanjiushu5063 2015-02-13 19:13
浏览 239

PHP文件上的互斥锁(锁定文件)

hi guys i searched a lot but i get stocked on this one

i have a Mutex class witch basically is using flock and it will lock a file just fine but my script is running over about 200~ above users so because of this my Server Hard Drive will always working a lot and this is very expensive for my work so i need a very simple solution to lock a file like flock but not touching the HDD .

i tested PECL extention ( i dont know this will fixed my problem either ) but its really hard to config and use it.

thanks in advance and sorry for my bad English

  • 写回答

1条回答 默认 最新

  • dongzhan7909 2018-08-16 11:27
    关注

    You could set up a ram drive under both Linux and Windows and store your lock files there. I have a similar system and since they are so small (empty files so only file meta data) even a few megabytes can store quite a lot of them. Another upside with this is that a system reboot will delete all lockfile's so no lingering ones are left on the drive.

    On Linux you could add something like the following to /etc/fstab

    tmpfs       /mnt/ramdisk tmpfs   nodev,nosuid,noexec,nodiratime,size=1024M   0 0
    

    On Windows you can download something like ImDisk Toolkit and create a ramdisk with that.

    ImDisk RamDisk Configuration Tool

    评论

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了