PHP code example of jdwx / array-cache

1. Go to this page and download the library: Download jdwx/array-cache 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/ */

    

jdwx / array-cache example snippets


use JDWX\ArrayCache\ArrayCache;


$cache = new ArrayCache([ 'foo' => 'bar', 'baz' => 'qux' ]);

$cache = new ArrayCache();
$cache->set( 'foo', 'bar' );
$cache->set( 'baz', 'qux', 5 );
$json = json_encode($cache);

$st = '{"foo":"bar","baz":"qux"}';
$cache = new ArrayCache($st);
assert( $cache->get('foo') === 'bar' );
assert( $cache->get('baz') === 'qux' );

// or

$cache = new ArrayCache();
$cache->set( 'foo', 'bar' );
$cache->set( 'baz', 'qux', 5 );
$cache->set( 'quux', 'corge' );

$st = json_encode($cache);

$cache = new ArrayCache($st);
assert( $cache->get('foo') === 'bar' );