MatthiasMullie\Scrapbook\Adapters\Apc::acquire PHP 메소드

acquire() 보호된 메소드

Acquire a lock - required to provide CAS functionality.
protected acquire ( string | string[] $keys ) : string[]
$keys string | string[]
리턴 string[] Array of successfully locked keys
    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);
    }