PHP code example of takuya / php-sysv-ipc-shared-memory
1. Go to this page and download the library: Download takuya/php-sysv-ipc-shared-memory library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
takuya / php-sysv-ipc-shared-memory example snippets
$uniq_name = 'shm_name';
$shm = new IPCSharedMem($uniq_name);
$shm->put(new MyClass());
//
$obj = $shm->get();// instance of MyClass;
// remove ipc
$shm->destroy()
$idx = 'key';
$store = new IPCShmKeyStore('shm_name');
$store->runWithLock(function($store)use($idx){
$store->set($store,$shm->get($idx)+1);
});
$store = new IPCShmKeyStore('kvs-like', 1024*1024);
// Set by key
$store->set('key',['msg'=>'Auxakai3']);
// Get by key
$store->get('key')['msg']; // => Auxakai3