国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

redis - PHP ?? ???? ??? ??, ??? ??????
僅有的幸福
僅有的幸福 2017-05-16 13:09:23
0
1
708

PHP ?? ???? ??? ??? ???? ??? ??????

 ?? ?? acquire($key) {
        //? ?? ??? ??? ???? ?? ??
        if ( is_array($key) && count($key) == 2 ) {
            ?? (?) {
                $res = ??();
                foreach($key as $k => $v) {
                    $res[$k] = $this->acquire($v);
                    if ( !$res[$k] ) {
                        ????;
                    }
                }
                //? ?? ??? ?? ?? ?? ?? ??
                if ( !$res[0] ) {
                    $err = new SysErr(System::MEMCACHE_ACQUIRE_LOCK_ERROR);
                    ErrorHandle::throwErr($err);
                } elseif( !$res[1] ) {
                    //? ?? ??? ???? ????? ?? ?????.
                    $this->release($key[0]);
                    usleep(LockConfig::LOCK_TIMEWAIT);
                } ? ?? {
                    TRUE? ?????.
                }
            }
        } ? ?? {
            $lock_key = LockConfig::LOCK_PREFIX .
            $i = 0;
            ?? {
                $lock = $this->_memcache->add( $lock_key, 1, LockConfig::LOCK_TIMEOUT );
                //???? Lock? ???? ?? ??, ??? ?? ?? ??? ? ?? ????.
                if ($i > 0) {
                    usleep(LockConfig::LOCK_TIMEWAIT);
                }
                $i++;
                //??? ?? ?? ? ??
                if ($i > LockConfig::LOCK_RETRY_TIMES) {
                    $err = new SysErr(System::MEMCACHE_ACQUIRE_LOCK_ERROR);
                    ErrorHandle::throwErr($err);
                }
            } ??( !$lock );

            // ?? ??
            if ($i > 1) {
                LogHelper::warning('lock.log', "{$i}? ?? '{$lock_key}' ?? ??");
            }
            $??? ?????.
        }
    }
    
    
      /**
     * ??? ?? ??
     *
     * @param string $key ??? ??? ???? ??? ?? ? ?
     * @return bool ????? ???? TRUE? ?????.
     */
    ?? ?? ???($key) {
        $lock_key = LockConfig::LOCK_PREFIX .
        return $this->_memcache->delete($lock_key);
    }
僅有的幸福
僅有的幸福

?? ??(1)
為情所困

???? ????? ???? ????. Redis ??? ?? ????? ???? Mysql ??? ??? ? ??? ???. .

??? ??? ??? ?????? ??????:
$lock = new CacheLock('key_name')
$lock->lock();
//logic here
$lock->unlock( );
CacheLock ???? ??? ??? ??? SQL ??? ??????? ???? ?? ???? ?? ? ?? ?? ???? ?? ??? ?????. ??? ? PHP? ?? ??? ???? ??? ?? ???? ? ??? ???? ? ?????. /eaccelerator. ??? ?? ?? eaccelerator? ???? ?? ??? ???? ?? ????? ?? ????? ??? ?????. eaccelerator? ???? ??? ????? ???? ??? ?? ???? ????? ????. mysql innodb? ?? ??.