Jamm\Memory\Shm\SHMObject::lock_key PHP Метод

lock_key() публичный Метод

Example: Process 1 reads key simultaneously with Process 2. Value of this key are too old, so Process 1 going to refresh it. Simultaneously with Process 2. But both of them trying to lock_key, and Process 1 only will refresh value of key (taking it from database, e.g.), and Process 2 can decide, what he want to do - use old value and not spent time to database, or something else.
public lock_key ( mixed $key, mixed &$auto_unlocker_variable ) : boolean
$key mixed
$auto_unlocker_variable mixed - pass empty, just declared variable
Результат boolean
    public function lock_key($key, &$auto_unlocker_variable)
    {
        $r = $this->mem_object->add(self::lock_key_prefix . $key, 1, $this->key_lock_time);
        if (!$r) {
            return false;
        }
        $auto_unlocker_variable = new \Jamm\Memory\KeyAutoUnlocker(array($this, 'unlock_key'));
        $auto_unlocker_variable->setKey($key);
        return true;
    }