On Tue, 2004-02-17 at 06:07, Derick Rethans wrote:
> I don't want to plug anything, but have a look at www.vl-srm.net; it
> tries to achive this (note: site is a bit outdated).

You don't have to plugin anything, you can do it in PHP and the data
storage method of your choice.  Keep in mind that srm is a PHP extension
and therefore less portable than just using PHP code.  Srm's design is
certainly much more robust than what I have below, but here's a basic
pseudo code example of global variables using shared memory and very
simple locking.  You could extend this to also save and restore static
variables in objects.

function retrieveGlobalVar($var_name) {
  if (shmGetVal($var_name . '-lock') == '0') {
    // grab variable from storage
    $val = unserialize(shmGetVal($var_name));
    // Lock variable automatically
    lockGlobalVar($var_name);
    // return variable
    return $val;
  } else {
    // Locked
    return null;
  }
}
function saveAndReleaseGlobalVar($var_name, $var) {
  // save variable
  shmSetVal($var_name, serialize($var));
  // Unlock variable automatically
  unlockGlobalVar($var_name);
}
function deleteGlobalVar($var_name) {
  // Delete variable
  shmDeleteVal($var_name);
  // Delete variable's locking value
  shmDeleteVal($var_name . '-lock');
}
function lockGlobalVar($var_name) {
  // mark variable as locked
  shmSetVal($var_name . '-lock', '1');
}
function unlockGlobalVar($var_name) {
  // mark variable as unlocked
  shmSetVal($var_name . '-lock', '0');
}

Regards,
Adam

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to