PHP code example of takuya / php-sharedmemory-keystore

1. Go to this page and download the library: Download takuya/php-sharedmemory-keystore 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-sharedmemory-keystore example snippets



$uniq_name = 'uniq_name_for_shm'
$store = new ShmArrayStore($uniq_name);
$store['key']=new stdClass();
$obj = $shm->get('key');// instance of MyClass;
// remove ipc
$shm->destroy()


$store = new ShmArrayStore('my-shm', 1024);
$store->runWithLock(function($store)use($idx){
  $store->set(0,($store->get(0) ?? 0)+$idx);
});
}


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


 $shm = new ShmOperator(str_rand(), 100);
 $shm->put($msg);
 $shm->get();
 $shm->erase();
 $shm->isEmpty();
 $shm->get();
 $shm->destroy();
shell
composer 
shell
name='takuya/php-sharedmemory-keystore'
[email protected]:$name.git
composer config repositories.$name vcs $repo
composer