Added documentation and renamed function
This commit is contained in:
parent
f4652d6e50
commit
286b2da7a9
2 changed files with 28 additions and 28 deletions
|
@ -2,10 +2,10 @@ Table locks
|
|||
===========
|
||||
|
||||
| Field | Description | Type | Null | Key | Default | Extra |
|
||||
|---------|------------------|--------------|------|-----|---------------------|----------------|
|
||||
|---------|------------------|------------------|------|-----|---------------------|----------------|
|
||||
| id | sequential ID | int(11) | NO | PRI | NULL | auto_increment |
|
||||
| name | | varchar(128) | NO | | | |
|
||||
| locked | | tinyint(1) | NO | | 0 | |
|
||||
| created | | datetime | YES | | 0001-01-01 00:00:00 | |
|
||||
| pid | | int(10) unsigned | NO | | 0 | |
|
||||
|
||||
Return to [database documentation](help/database)
|
||||
|
|
|
@ -22,7 +22,7 @@ class Lock {
|
|||
*
|
||||
* @return object|boolean The memcache object - or "false" if not successful
|
||||
*/
|
||||
public static function memcache() {
|
||||
private static function connect_memcache() {
|
||||
if (!function_exists('memcache_connect')) {
|
||||
return false;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class Lock {
|
|||
$got_lock = false;
|
||||
$start = time();
|
||||
|
||||
$memcache = self::memcache();
|
||||
$memcache = self::connect_memcache();
|
||||
if (is_object($memcache)) {
|
||||
$wait_sec = 0.2;
|
||||
$cachekey = get_app()->get_hostname().";lock:".$fn_name;
|
||||
|
@ -126,7 +126,7 @@ class Lock {
|
|||
* @param string $fn_name Name of the lock
|
||||
*/
|
||||
public static function remove($fn_name) {
|
||||
$memcache = self::memcache();
|
||||
$memcache = self::connect_memcache();
|
||||
if (is_object($memcache)) {
|
||||
$cachekey = get_app()->get_hostname().";lock:".$fn_name;
|
||||
$lock = $memcache->get($cachekey);
|
||||
|
@ -147,7 +147,7 @@ class Lock {
|
|||
* @brief Removes all lock that were set by us
|
||||
*/
|
||||
public static function removeAll() {
|
||||
$memcache = self::memcache();
|
||||
$memcache = self::connect_memcache();
|
||||
if (is_object($memcache)) {
|
||||
// We cannot delete all cache entries, but this doesn't matter with memcache
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue