public class Mutex

class.mutex.php #10

The Mutex class is a crude locking class that generates files with a specific time to live. It has basic functions to create a lock, release a lock or refresh a lock.

Methods

public static
class.mutex.php #29
static boolean acquire()

Creates a lock file if one does not already exist with a certain time to live (TTL) at a specific path. If a lock already exists, false will be returned otherwise boolean depending if a lock file was created successfully or not.

Parameters
  • $id The name of the lock file, which gets obfuscated using generateLockFileName.

  • $ttl The length, in seconds, that the lock should exist for. Defaults to 5.

  • $path The path the lock should be written, defaults to the current working directory

static boolean lockExists()

Checks if a lock exists, purely on the presence on the lock file. This function takes the unobfuscated lock name

Parameters
  • $id The name of the lock file, which gets obfuscated using generateLockFileName.

  • $path The path the lock should be written, defaults to the current working directory

public static
class.mutex.php #73
static boolean refresh()

Updates a lock file to 'keep alive' for another 'x' seconds.

Parameters
  • $id The name of the lock file, which gets obfuscated using __generateLockFileName().

  • $ttl The length, in seconds, that the lock should be extended by. Defaults to 5.

  • $path The path to the lock, defaults to the current working directory

public static
class.mutex.php #52
static boolean release()

Removes a lock file. This is the only way a lock file can be removed

Parameters
  • $id The original name of the lock file (note that this will be different from the name of the file saved on the file system)

  • $path The path to the lock, defaults to the current working directory

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details