PHP Classes

ipcContainer: Share variables between tasks with shared memory

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 152 All time: 9,068 This week: 455Up
Version License PHP version Categories
ipc-container 1.0Public Domain5.0PHP 5, Language
Description 

Author

This class can share variables between tasks with shared memory.

It can attach to a given shared memory segment so it can store and retrieve values to be shared with other processes that access the memory segment with the same key.

Assigning variable values to the class variables will make it store the values in an associative array to be stored in the attached shared memory segment.

Likewise, retrieving variables of the class will retrieve values with the same index name from the array stored in the share memory segment.

Picture of Matthew Knowlton
  Performance   Level  
Name: Matthew Knowlton <contact>
Classes: 6 packages by
Country: United States United States
Innovation award
Innovation award
Nominee: 4x

Winner: 1x

Example

<?php
require_once('ipcContainer.class.php');

//open two shared memory slots
$container1 = new ipcContainer('1234');
$container2 = new ipcContainer('4321');

//opening a pointer to the same ipcContainer as container2
//for testing purposes
$container3 = new ipcContainer('4321');

//write variable "test" differently into each slot
$container1->test = array('hello' => 'world');
$container2->test = 'hello world';
//this data is immediately available on any other process or any other container with the same id
//and can be immediately overwritten by another container with the same id
$container3->test = 'Goodbye planet!!!';

//show the stored data
//container1 will print the ['hello' => 'world']
echo '$container1 variable test set to '.print_r($container1->test,true).";<br/>";

//container2 will print 'Goodbye planet!!!'
//because it is accessing the same ipcContainer as container3
echo '$container2 variable test set to '.print_r($container2->test,true).";<br/>";
echo
'$container3 variable test set to '.print_r($container3->test,true).";<br/>";
?>


  Files folder image Files (3)  
File Role Description
Plain text file ipcContainer.class.php Class Class Source
Accessible without login Plain text file ipcContainer.example1.php Example Example Script
Accessible without login Plain text file ipcContainer.example2.php Example Example Script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:152
This week:0
All time:9,068
This week:455Up