/**
  * @param string $path
  * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  */
 public function releaseLock($path, $type)
 {
     if ($type === self::LOCK_SHARED) {
         if (isset($this->acquiredLocks['shared'][$path]) and $this->acquiredLocks['shared'][$path] > 0) {
             $this->memcache->dec($path);
             $this->memcache->cad($path, 0);
         }
     } else {
         if ($type === self::LOCK_EXCLUSIVE) {
             $this->memcache->cad($path, 'exclusive');
         }
     }
     $this->markRelease($path, $type);
 }
 /**
  * @param string $path
  * @param int $type self::LOCK_SHARED or self::LOCK_EXCLUSIVE
  */
 public function releaseLock($path, $type)
 {
     if ($type === self::LOCK_SHARED) {
         if ($this->getOwnSharedLockCount($path) === 1) {
             $removed = $this->memcache->cad($path, 1);
             // if we're the only one having a shared lock we can remove it in one go
             if (!$removed) {
                 //someone else also has a shared lock, decrease only
                 $this->memcache->dec($path);
             }
         } else {
             // if we own more than one lock ourselves just decrease
             $this->memcache->dec($path);
         }
     } else {
         if ($type === self::LOCK_EXCLUSIVE) {
             $this->memcache->cad($path, 'exclusive');
         }
     }
     $this->markRelease($path, $type);
 }