示例#1
0
 public function merge($key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0)
 {
     if (wincache_lock($key)) {
         // optimize with FIFO lock
         $ok = $this->mergeViaLock($key, $callback, $exptime, $attempts, $flags);
         wincache_unlock($key);
     } else {
         $ok = false;
     }
     return $ok;
 }
示例#2
0
 /**
  * Obtains a named lock.
  * 
  * @param string $key     Name of the key to obtain. Note that $key may
  *     repeat for each distinct $persistentId.
  * @param double $timeout Ignored with WinCache. Script will always block if
  *     the lock can't be immediatly obtained.
  * 
  * @return bool TRUE on success, FALSE on failure.
  */
 public function lock($key, $timeout = null)
 {
     $result = wincache_lock($this->persistentId . static::encodeLockName($key));
     if ($result) {
         static::$locksBackup[$this->persistentId] = $key;
     }
     return $result;
 }