hheedat
V2EX  ›  PHP

PHP apcu 扩展,进程之间是安全的么?

  •  
  •   hheedat · Dec 1, 2017 · 2765 views
    This topic created in 3110 days ago, the information mentioned may be changed or developed.

    搜了下,没找到明确的资料,官方文档也没有提及,望知情人士解答一下,谢谢了

    https://pecl.php.net/package/APCu

    http://php.net/apcu

    https://stackoverflow.com/questions/45168588/is-apc-store-thread-safe

    apcu

    2 replies    2017-12-01 20:19:53 +08:00
    picone
        1
    picone  
       Dec 1, 2017   ❤️ 1
    是线程安全的。

    apcu 内部是有定义锁的相关宏,有两对锁:APC_LOCK 和 APC_UNLOCK,APC_RLOCK 和 APC_RUNLOCK,具体实现似乎平台,在 apc_lock.c 中有相关的实现。
    在 apcu 在根据 key 来进行查找时会使用 APC_RLOCK 锁定这个 key,插入、删除和修改时会有使用 APC_LOCK 锁定,具体实现在 apc_cache.c
    hheedat
        2
    hheedat  
    OP
       Dec 1, 2017
    @picone 感谢你的回复
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2889 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:45 · PVG 13:45 · LAX 22:45 · JFK 01:45
    ♥ Do have faith in what you're doing.