项目作者: php-comp

项目描述 :
shared memory operate of the php. php 共享内存操作的实现
高级语言: PHP
项目地址: git://github.com/php-comp/shared-memory.git
创建时间: 2017-06-03T11:47:35Z
项目社区:https://github.com/php-comp/shared-memory

开源协议:MIT License

关键词:
php-library shared-memory

下载


php 共享内存

License
Php Version
Latest Stable Version

php 共享内存操作的实现。基于

  • sysvshm扩展:实现system v方式的共享内存 linux/mac
  • shmop扩展:共享内存操作扩展 linux/mac/windows

功能:

  • 实现了共享内存的 写入 读取 删除 释放 基本操作
  • 扩展的类 ShmMap 实现了基于共享内存的数组结构(数组方式操作、pop/push、迭代器,读/取都会自动加锁)。

安装

  • composer
  1. {
  2. "require": {
  3. "php-comp/shm": "dev-master"
  4. }
  5. }
  • 直接拉取
  1. git clone https://github.com/php-comp/shared-memory.git // github

使用

  1. use PhpComp\Shm\ShmFactory;
  2. use PhpComp\Shm\ShmMap;
  3. $shm = ShmFactory::make([
  4. 'key' => 1,
  5. 'size' => 512
  6. ]);
  7. $shm->write('data string');
  8. $ret = $shm->read();
  9. var_dump($ret);
  10. $shmAry = new ShmMap([
  11. 'key' => 2,
  12. 'size' => 512
  13. ]);
  14. $shmAry['one'] = 'val1';
  15. $shmAry['two'] = 'val2';
  16. $shmAry->set('three', 'val3');
  17. var_dump($shmAry['three'], $shmAry->getMap());
  18. unset($shmAry['two']);
  19. var_dump($shmAry->getMap());

License

MIT