Stiphle\Storage\StorageInterface::lock PHP Метод

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

We might have multiple requests coming in at once, so we lock the storage
public lock ( $key ) : void
Результат void
    public function lock($key);

Usage Example

Пример #1
0
 /**
  * Throttle
  *
  * @param string $key  - A unique key for what we're throttling
  * @param int $limit   - How many are allowed
  * @param int $milliseconds - In this many milliseconds
  * @return void
  */
 public function throttle($key, $limit, $milliseconds)
 {
     /**
      * Try do our waiting without a lock, so may sneak through because of
      * this...
      */
     $wait = $this->getEstimate($key, $limit, $milliseconds);
     if ($wait > 0) {
         usleep($wait * 1000);
     }
     $key = $this->getStorageKey($key, $limit, $milliseconds);
     $this->storage->lock($key);
     $count = $this->storage->get($key);
     $count++;
     $this->storage->set($key, $count);
     $this->storage->unlock($key);
     return $wait;
 }
All Usage Examples Of Stiphle\Storage\StorageInterface::lock