• 请不要在回答技术问题时复制粘贴 AI 生成的内容
wdy1184
V2EX  ›  程序员

如何控制同时只有一个人访问一个 php 文件?

  •  
  •   wdy1184 · Jun 30, 2015 · 4492 views
    This topic created in 4004 days ago, the information mentioned may be changed or developed.

    如题。

    Supplement 1  ·  Jul 1, 2015
    题目说的不明白,补充一下。
    在网站运行时,有个php的文件,注意不是界面,需要同时只有一个人访问。
    就是在同一时间,不能有两个人访问了站点下面的a.php。
    14 replies    2015-07-04 21:52:56 +08:00
    bombless
        1
    bombless  
       Jun 30, 2015
    在入口去获取文件锁吧
    Septembers
        2
    Septembers  
       Jun 30, 2015
    悲观锁
    woshicixide
        3
    woshicixide  
       Jun 30, 2015
    flock
    littlehz
        4
    littlehz  
       Jun 30, 2015
    先说需求,再来谈技术实现,也许你完全走错了方向。
    hdjdcyl
        5
    hdjdcyl  
       Jul 1, 2015 via iPhone
    lilydjwg
        6
    lilydjwg  
       Jul 1, 2015
    嗯,这是 Y。同求 X。——http://coolshell.cn/articles/10804.html
    Clarencep
        7
    Clarencep  
       Jul 1, 2015
    @lilydjwg +1
    LZ先介绍下背景吧,这个问题有点怪异
    sampeng
        8
    sampeng  
       Jul 1, 2015
    我猜是svn的权限管理。。。
    yexiaoxing
        9
    yexiaoxing  
       Jul 1, 2015 via iPad
    是运行还是写入/读取该文件?
    wdy1184
        10
    wdy1184  
    OP
       Jul 1, 2015
    @bombless 是在网站运行的时候
    wdy1184
        11
    wdy1184  
    OP
       Jul 1, 2015
    @Septembers 求解释。。。
    wdy1184
        12
    wdy1184  
    OP
       Jul 1, 2015
    @littlehz @lilydjwg @Clarencep 面试的时候面试官问的问题。当时没问他用这个来实现什么。
    wdy1184
        13
    wdy1184  
    OP
       Jul 1, 2015
    @yexiaoxing 运行的时候
    realpg
        14
    realpg  
    PRO
       Jul 4, 2015
    先看选型,架构里有没有memcache之类缓存系统,没有就用文件,创建一个标志锁就行了,占用时候设置,退出时候删除
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1023 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 18:49 · PVG 02:49 · LAX 11:49 · JFK 14:49
    ♥ Do have faith in what you're doing.