PHP 8.5.0 Alpha 4 available for testing

Voting

: min(seven, zero)?
(Example: nine)

The Note You're Voting On

novayear # hotmail ; com
11 years ago
small shm class..
example usage:
$shx= new shmSmart;
$shx->put("key_name_apple","key_val_peach"); //set example..
$shx->put("key name alternative array",array(1=>"banana","apricot","blablabla"=>array("new-blaala"))); //set array example..
echo $shx->get("key_name_apple"); // get example key value.
$shx->del("key_name_apple"); // delete key
unset($shx); // free memory in php..

class shmSmart{
public $shm; //holds shared memory resource
public function __construct(){
if(function_exists("shm_attach")===FALSE){
die("\nYour PHP configuration needs adjustment. See: http://us2.php.net/manual/en/shmop.setup.php. To enable the System V shared memory support compile PHP with the option --enable-sysvshm.");
}
$this->attach(); //create resources (shared memory)
}
public function attach(){
$this->shm=shm_attach(0x701da13b,33554432); //allocate shared memory
}
public function dettach(){
return shm_detach($this->shm); //allocate shared memory
}
public function remove(){
return shm_remove($this->shm); //dallocate shared memory
}
public function put($key,$var) {
return shm_put_var($this->shm,$this->shm_key($key),$var); //store var
}
public function get($key){
if($this->has($key)){
return shm_get_var($this->shm,$this->shm_key($key)); //get var
}else{
return false;
}
}
public function del($key){
if($this->has($key)){
return shm_remove_var($this->shm,$this->shm_key($key)); // delete var
}else{
return false;
}
}
public function has($key){
if(shm_has_var($this->shm,$this->shm_key($key))){ // check is isset
return true;
}else{
return false;
}
}
public function shm_key($val){ // enable all world langs and chars !
return preg_replace("/[^0-9]/","",(preg_replace("/[^0-9]/","",md5($val))/35676248)/619876); // text to number system.
}
public function __wakeup() {
$this->attach();
}
public function __destruct() {
$this->dettach();
unset($this);
}
}

<< Back to user notes page

To Top