PHP code example of adammbalogh / key-value-store-null

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



use AdammBalogh\KeyValueStore\KeyValueStore;
use AdammBalogh\KeyValueStore\Exception\KeyNotFoundException;
use AdammBalogh\KeyValueStore\Adapter\NullAdapter as Adapter;

$adapter = new Adapter();

$kvs = new KeyValueStore($adapter);

$kvs->set('sample_key', 'Sample value');
try {
    $kvs->get('sample_key');
} catch (KeyNotFoundException $e) {
    // null adapter's get method throws KeyNotFoundException
}
$kvs->delete('sample_key');