src/Adapters/Apc.php
protected function lock($keys)
    {
        // both string (single key) and array (multiple) are accepted
        $keys = (array) $keys;

        $locked = array();
        for ($i = 0; $i < 10; ++$i) {
            $locked += $this->acquire($keys);
            $keys = array_diff($keys, $locked);

            if (empty($keys)) {
                break;
            }

            usleep(1);
        }

        return $locked;
    }
protected function lock($keys)
    {
        // both string (single key) and array (multiple) are accepted
        $keys = (array) $keys;

        $locked = array();
        for ($i = 0; $i < 10; ++$i) {
            $locked += $this->acquire($keys);
            $keys = array_diff($keys, $locked);

            if (empty($keys)) {
                break;
            }

            usleep(1);
        }

        return $locked;
    }
protected function lock ( $ keys ) { // both string (single key) and array (multiple) are accepted $ keys = ( array ) $ keys ; $ locked = array ( ) ; for ( $ i = 0 ; $ i < 10 ; ++ $ i ) { $ locked += $ this -> acquire ( $ keys ) ; $ keys = array_diff ( $ keys , $ locked ) ; if ( empty ( $ keys ) ) { break ; } usleep ( 1 ) ; } return $ locked ; }
Acquire a lock. If we failed to acquire a lock, it'll automatically try
again in 1ms, for a maximum of 10 times.

APC provides nothing that would allow us to do CAS. To "emulate" CAS,
we'll work with locks: all cache writes also briefly create a lock
cache entry (yup: #writes * 3, for lock & unlock - luckily, they're
not over the network)
Writes are disallows when a lock can't be obtained (= locked by
another write), which makes it possible for us to first retrieve,
compare & then set in a nob-atomic way.
However, there's a possibility for interference with direct APC
access touching the same keys - e.g. other scripts, not using this
class. If CAS is of importance, make sure the only things touching
APC on your server is using these classes!

@param string|string[] $keys

@return array Array of successfully locked keys
Acquire a lock . If we failed to acquire a lock it ll automatically try again in 1ms for a maximum of 10 times .