hheedat
V2EX  ›  PHP

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

  •  
  •   hheedat · Dec 1, 2017 · 3055 views
    This topic created in 3261 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
    picone
    Dec 1, 2017❤️1
    1
    是线程安全的。

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