Class mr_lock

Description

MR Lock

This class is used to get a process safe lock. Basic use case for this is to prevent code from running at the same time in different requests, like running a cron on top of itself.

Example usage:

  1.  <?php
  2.      $lock new mr_lock('admin_cron');
  3.      if ($lock->get()) {
  4.          // Do work here that requires a lock
  5.  
  6.          // Release the lock when done
  7.          $lock->release();
  8.      }
  9.  ?>

  • author: Mark Nielsen

Located in /lock.php (line 54)


	
			
Variable Summary
Method Summary
mr_lock __construct (string $uniquekey, [int $timetolive = NULL], [string $backend = NULL])
boolean get ()
boolean release ()
void shutdown ()
Variables
mr_lock_abstract $backend (line 60)

The mechanism used for acquiring the lock

  • access: protected
Methods
Constructor __construct (line 70)

Lock setup

  • access: public
mr_lock __construct (string $uniquekey, [int $timetolive = NULL], [string $backend = NULL])
  • string $uniquekey: This key is used to generate the key for the lock. Example values: mod_quiz_cron, admin_cron, etc.
  • int $timetolive: The number of seconds until the lock expires completely. Default is 8 hours.
  • string $backend: The backend to use for the locking mechanism. Generally, don't pass this.
get (line 100)

Try to acquire the lock

  • access: public
boolean get ()
release (line 113)

Release the lock

  • access: public
boolean release ()
shutdown (line 91)

Release the lock on shutdown.

  • access: public
void shutdown ()

Documentation generated on Thu, 28 Jun 2012 16:33:49 -0700 by phpDocumentor 1.4.3