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 // githubuse PhpCompShmShmFactory;
use PhpCompShmShmMap;
$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