public function throttle($key, $limit, $milliseconds)
    {
        /**
         * Try and do our waiting without a lock
         */
        $key = $this->getStorageKey($key, $limit, $milliseconds); 
        $wait     = 0;
        $newRatio = $this->getNewRatio($key, $limit, $milliseconds);

        if ($newRatio > $milliseconds) {
            $wait = ceil($newRatio - $milliseconds);
        }
        usleep($wait * 1000);

        /**
         * Lock, record and release 
         */
        $this->storage->lock($key);
        $newRatio = $this->getNewRatio($key, $limit, $milliseconds);
        $this->setLastRatio($key, $newRatio);
        $this->setLastRequest($key, microtime(1));
        $this->storage->unlock($key);
        return $wait;
    }
public function throttle($key, $limit, $milliseconds)
    {
        
        $key = $this->getStorageKey($key, $limit, $milliseconds); 
        $wait     = 0;
        $newRatio = $this->getNewRatio($key, $limit, $milliseconds);

        if ($newRatio > $milliseconds) {
            $wait = ceil($newRatio - $milliseconds);
        }
        usleep($wait * 1000);

        
        $this->storage->lock($key);
        $newRatio = $this->getNewRatio($key, $limit, $milliseconds);
        $this->setLastRatio($key, $newRatio);
        $this->setLastRequest($key, microtime(1));
        $this->storage->unlock($key);
        return $wait;
    }
public function throttle ( $ key , $ limit , $ milliseconds ) { /**
         * Try and do our waiting without a lock
         */ $ key = $ this -> getStorageKey ( $ key , $ limit , $ milliseconds ) ; $ wait = 0 ; $ newRatio = $ this -> getNewRatio ( $ key , $ limit , $ milliseconds ) ; if ( $ newRatio > $ milliseconds ) { $ wait = ceil ( $ newRatio - $ milliseconds ) ; } usleep ( $ wait * 1000 ) ; /**
         * Lock, record and release 
         */ $ this -> storage -> lock ( $ key ) ; $ newRatio = $ this -> getNewRatio ( $ key , $ limit , $ milliseconds ) ; $ this -> setLastRatio ( $ key , $ newRatio ) ; $ this -> setLastRequest ( $ key , microtime ( 1 ) ) ; $ this -> storage -> unlock ( $ key ) ; return $ wait ; }
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 int
Throttle