Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
SimpleSHM is a simple and small abstraction layer for shared memory manipulation using PHP. It makes use of the SHMOP functions, built into most PHP packages.
PHP
Tree: 002f8beecc

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tests
.travis.yml
LICENSE.txt
README.markdown
SimpleSHM.php
demo.php

README.markdown

SimpleSHM

Build Status SimpleSHM is a simple and small abstraction layer for shared memory manipulation using PHP. It makes use of the SHMOP functions, built into most PHP packages.

Authors and contributors

License

New BSD license

Todo

  • add support for arrays, by automatically serializing or converting to JSON
  • add support for objects, by using JSON
  • create a better documentation
  • error handling can, and should, be improved
  • test, test, test

About Shared Memory

Shared Memory is an efficient mean of exchanging data between applications in the same machine. One application will create a memory portion which other processes can access, as long as they have the proper permissions. You can read more about it here: http://stereochro.me/assets/uploads/notes/dcom3/shmem.pdf

Using SimpleSHM

The idea behind SimpleSHM is to keep things very easy to use. If you want better control and flexibility, you can always modify the class or extend it.

<?php 

/**
 * Creating new block, with a random ID
 */
$memory = new SimpleSHM;
$memory->write('Sample');
echo $memory->read();

/**
 * Creating new block, with an specified ID
 */
$new = new SimpleSHM(897);
$new->write('Sample');
echo $new->read();

/**
 * Reading an existing block, with the ID of 42
 */
$existing = new SimpleSHM(42);
echo $existing->read();
Something went wrong with that request. Please try again.