GithubHelp home page GithubHelp logo

nestdimon / shared-memory Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phppkg/shared-memory

0.0 1.0 0.0 26 KB

shared memory operate of the php. php 共享内存操作的实现

License: MIT License

PHP 100.00%

shared-memory's Introduction

php 共享内存

License Php Version Latest Stable Version

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

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

功能:

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

安装

  • composer
{
    "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());

License

MIT

shared-memory's People

Contributors

inhere avatar

Watchers

NDS avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.