PHP code example of adammbalogh / key-value-store-shared-memory

1. Go to this page and download the library: Download adammbalogh/key-value-store-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/ */

    

adammbalogh / key-value-store-shared-memory example snippets



use AdammBalogh\KeyValueStore\KeyValueStore;
use AdammBalogh\KeyValueStore\Adapter\SharedMemoryAdapter as Adapter;

$tmpFileName = tempnam('/tmp', 'KVS');
$shmResource = shm_attach(ftok($tmpFileName, 'a'));
if ( ! $shmResource) {
    die('Unable to create the shared memory segment');
}

$adapter = new Adapter($shmResource);

$kvs = new KeyValueStore($adapter);

$kvs->set('sample_key', 'Sample value');
$kvs->get('sample_key');
$kvs->delete('sample_key');