Building for Windows> <wincache_ucache_set
Last updated: Fri, 24 Feb 2012

wincache_unlock

(PECL wincache >= 1.1.0)

wincache_unlock Releases an exclusive lock on a given key

Descrição

bool wincache_unlock ( string $key )

Releases an exclusive lock that was obtained on a given key by using wincache_lock(). If any other process was blocked waiting for the lock on this key, that process will be able to obtain the lock.

Aviso

Using of the wincache_lock() and wincache_unlock() can cause deadlocks when executing PHP scripts in a multi-process environment like FastCGI. Do not use these functions unless you are absolutely sure you need to use them. For the majority of the operations on the user cache it is not necessary to use these functions.

Parâmetros

key

Name of the key in the cache to release the lock on.

Valor Retornado

Retorna TRUE em caso de sucesso ou FALSE em falhas.

Exemplos

Exemplo #1 Using wincache_unlock()

<?php
$fp 
fopen("/tmp/lock.txt""r+");
if (
wincache_lock(“lock_txt_lock”)) { // do an exclusive lock
    
ftruncate($fp0); // truncate file
    
fwrite($fp"Write something here\n");
    
wincache_unlock(“lock_txt_lock”); // release the lock
} else {
    echo 
"Couldn't get the lock!";
}
fclose($fp);
?>

Veja Também



User Contributed Notes
wincache_unlock
donraman at microsoft dot com
23-Apr-2010 10:12
User should be aware that character '\' is not allowed as part of lock name. The reason why backslash is not allowed is because we are using CreateMutex call as described at http://msdn.microsoft.com/en-us/library/ms682411(VS.85).aspx. As per this article third parameter cannot have '\' character which is the lock name.

This means below code will not work.

<?php

   $ret_val
= wincache_lock("C:\WINDOWS\Temp/cache");
   echo
$ret_val . '<br>';
  
$ret_val = wincache_unlock("C:\WINDOWS\Temp/cache");
   echo
$ret_val . '<br>';

?>

Building for Windows> <wincache_ucache_set
Last updated: Fri, 24 Feb 2012