Shared Memory exists in Asp.net and Java. In addition to using memcached and other alternatives, PHP also supports shared memory!
Install the shmop Extension
Find the PHP installation source file directory
# Cd/usr/local/php-5.4.0/EXT/shmop
#/Usr/local/PHP/bin/phpize
#./Configure -- With-PHP-Config =/usr/local/PHP/bin/PHP-config
# Make & make install
Compiled and installed
# Cd/usr/local/PHP/lib/PHP/extend/no-debug-non-zts-20100525/
One more shmop. So
Add shmop. So in PHP. ini
Extension = shmop. So
;;;;;;;;;;;;;;;;;;;
; Module Settings;
;;;;;;;;;;;;;;;;;;;
Phpinfo () Output
Write Data
<? PHP $ shmid = shmop_open (864, 'C', 0755,102 4); shmop_write ($ shmid, "Hello world! ", 0); phpinfo ();?>
Read data
<? PHP $ shmid = shmop_open (864, 'C', 0755,102 4); shmop_write ($ shmid, "Hello world! ", 0); echo shmop_read ($ shmid, 0, 11);?>
Reference: http://www.ibm.com/developerworks/cn/opensource/os-php-shared-memory/