src/Adapters/Apc.php
protected function acquire($keys)
    {
        $keys = (array) $keys;

        $values = array();
        foreach ($keys as $key) {
            $values["scrapbook.lock.$key"] = null;
        }

        // there's no point in locking longer than max allowed execution time
        // for this script
        $ttl = ini_get('max_execution_time');

        // lock these keys, then compile a list of successfully locked keys
        // (using the returned failure array)
        $result = (array) $this->apcu_add($values, null, $ttl);
        $failed = array();
        foreach ($result as $key => $err) {
            $failed[] = substr($key, strlen('scrapbook.lock.'));
        }

        return array_diff($keys, $failed);
    }
protected function acquire($keys)
    {
        $keys = (array) $keys;

        $values = array();
        foreach ($keys as $key) {
            $values["scrapbook.lock.$key"] = null;
        }

        // there's no point in locking longer than max allowed execution time
        // for this script
        $ttl = ini_get('max_execution_time');

        // lock these keys, then compile a list of successfully locked keys
        // (using the returned failure array)
        $result = (array) $this->apcu_add($values, null, $ttl);
        $failed = array();
        foreach ($result as $key => $err) {
            $failed[] = substr($key, strlen('scrapbook.lock.'));
        }

        return array_diff($keys, $failed);
    }
protected function acquire ( $ keys ) { $ keys = ( array ) $ keys ; $ values = array ( ) ; foreach ( $ keys as $ key ) { $ values [ "scrapbook.lock.$key" ] = null ; } // there's no point in locking longer than max allowed execution time // for this script $ ttl = ini_get ( 'max_execution_time' ) ; // lock these keys, then compile a list of successfully locked keys // (using the returned failure array) $ result = ( array ) $ this -> apcu_add ( $ values , null , $ ttl ) ; $ failed = array ( ) ; foreach ( $ result as $ key => $ err ) { $ failed [ ] = substr ( $ key , strlen ( 'scrapbook.lock.' ) ) ; } return array_diff ( $ keys , $ failed ) ; }
Acquire a lock - required to provide CAS functionality.

@param string|string[] $keys

@return string[] Array of successfully locked keys
Acquire a lock - required to provide CAS functionality .