/** * Acquire key * * @param string $key * @param integer $max_acquire * @return boolean */ public function acquire($key, $max_acquire = 1) { if ($this->string()->length($key) === 0) { throw new \InvalidArgumentException('Key is not set'); } $key = $this->string()->toUpper($key); if ($this->dictionary->has($key)) { $entity = $this->dictionary->get($key); } else { $entity = new MutexEntity(); $entity->generate($key, $max_acquire); if (Config::exists('mutex', 'perm')) { $entity->permission = Config::get('mutex', 'perm'); } $this->dictionary->add($key, $entity); } return $this->adaptor()->acquire($entity); }