shared memory
1.0.0
php 共享內存操作的實現。基於
linux/maclinux/mac/windows功能:
写入读取删除释放基本操作ShmMap實現了基於共享內存的數組結構(數組方式操作、pop/push、迭代器,讀/取都會自動加鎖)。 {
"require" : {
"php-comp/shm" : " dev-master "
}
}git clone https://github.com/php-comp/shared-memory.git // github use PhpComp Shm ShmFactory ;
use PhpComp Shm ShmMap ;
$ shm = ShmFactory:: make ([
' key ' => 1 ,
' size ' => 512
]);
$ shm -> write ( ' data string ' );
$ ret = $ shm -> read ();
var_dump ( $ ret );
$ shmAry = new ShmMap ([
' key ' => 2 ,
' size ' => 512
]);
$ shmAry [ ' one ' ] = ' val1 ' ;
$ shmAry [ ' two ' ] = ' val2 ' ;
$ shmAry -> set ( ' three ' , ' val3 ' );
var_dump ( $ shmAry [ ' three ' ], $ shmAry -> getMap ());
unset( $ shmAry [ ' two ' ]);
var_dump ( $ shmAry -> getMap ());MIT