
Originally Posted by
HarryR
application_register ('users');
$_APPLICATION['users']++; // When the session starts
// TODO: implement logic
$_APPLICATION['users']--; // And again when it ends
ArrayAcces interface onto the Semaphore extension perhaps?
Something like..
Code:
class SharedMemoryArray implements ArrayAccess
{
protected $shm;
function __construct($pathname, $project) { $this->shm = ftok($pathname, $project); }
function offsetGet($key) { return shm_get_var($this->shm, $key); }
function offsetSet($key, $value) { return shm_put_var($this->shm, $key, $value); }
function offsetUnset($key) { return shm_remove_var($this->shm, $key); }
function offsetExists($key) { return @shm_get_var($this->shm, $key) !== FALSE && ...something...; }
function __destruct() { @shm_detach($this->shm); }
}
class Application extends SharedMemoryArray
{
function __construct() { parent::__construct($_SERVER['DOCUMENT_ROOT'], ..something..); }
}
$_APPLICATION = new Application();
Haven't tried it, not sure it how well (if at all) it would work.
Would have some problems with offsetGet() not returning a reference I think.
And offsetExists() doesnt seem to have a natural equivalent shm_ function()
shm_get_var() returns FALSE and a warning when a $key doesnt exist.
Bookmarks