public function testTakeAndClearLock()
 {
     $key = 'take-and-clear';
     $handle = $this->throttle->takeLock($key, new DateTimeUnit(1, 'hour'));
     $this->assertInstanceOf('BeaucalLongThrottle\\Lock\\Handle', $handle);
     $keyApc = "beaucal_throttle::{$key}";
     $apc = new ApcExt();
     $this->assertTrue($apc->fetch($keyApc));
     $this->throttle->clearLock($handle);
     $this->assertFalse($apc->fetch($keyApc));
     /**
      * And again.
      */
     $this->throttle->clearLock($handle);
     $this->assertFalse($apc->fetch($keyApc));
 }
示例#2
0
 /**
  * @param Lock\Handle $handle
  */
 public function clearLock(Lock\Handle $handle)
 {
     if (!isset($this->locks[$handle->getToken()])) {
         return;
     }
     $key = $this->locks[$handle->getToken()];
     $this->apc->delete($key);
 }