承接 takuya/php-sysv-ipc-shared-memory 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

takuya/php-sysv-ipc-shared-memory

最新稳定版本:0.3.4

Composer 安装命令:

composer require takuya/php-sysv-ipc-shared-memory

包简介

php sysv shm wrapper

README 文档

README

This package is wrapper for php sysv shm_xxx.

Installing

from Packagist

composer require takuya/php-sysv-ipc-shared-memory

from GitHub

name='php-sysv-ipc-shared-memory' composer config repositories.$name \ vcs https://github.com/takuya/$name composer require takuya/$name:master composer install

Examples

<?php $uniq_name = 'shm_name'; $shm = new IPCSharedMem($uniq_name); $shm->put(new MyClass()); // $obj = $shm->get();// instance of MyClass; // remove ipc $shm->destroy()

Safer Access for update.

call get() then set() in the lock to update value using semaphore.

<?php $idx = 'key'; $store = new IPCShmKeyStore('shm_name'); $store->runWithLock(function($store)use($idx){ $store->set($store,$shm->get($idx)+1); });

More easy usage : Array Access.

This package offers KVS style access to Shared Memory.

<?php $store = new IPCShmKeyStore('kvs-like', 1024*1024); // Set by key $store->set('key',['msg'=>'Auxakai3']); // Get by key $store->get('key')['msg']; // => Auxakai3 

This package offers ArrayAccess style to use Shared Memory.

<?php $arr = new IPCShmKeyStore('array-like', 100); $arr[] = 'a'; $arr[] = 'b'; $arr[] = 'c'; foreach($arr as $e){ echo "$e,"; } // => "a,b,c,"

Limitation: ArrayAccess is not a real 'array'. Array functions ( ex array_map() ) cannot be applied for this.

comparison to shm_open

Compare to shared memory functions ( ex shmop_open()) , One big advantage SysV functions has.

Sysv function (ex shm_put_var) has auto serialization.

See Also.

I wrote these php code.

remove ipc by manually

If unused ipc remains. use SHELL command to remove.

ipcs -m | grep $USER | grep -oE '0x[a-f0-9]+' | xargs -I@ ipcrm --shmem-key @

统计信息

  • 总下载量: 2.83k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固