PHP code example of morphable / simple-cache

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

    

morphable / simple-cache example snippets




use \Morphable\SimpleCache;

// cache dir
$cache = new SimpleCache($root . '/.cache');
$cache->set('my_cache_item', $cacheItem);
$cache->exists('my_cache_item'); // true
$cache->get('my_cache_item');
$cache->delete('my_cache_item');




use \Morphable\SimpleCache\Exception\UnableToSerialize;
use \Morphable\SimpleCache\Exception\UnableToUnserialize;
use \Morphable\SimpleCache\SerializeInterface;

class MySerializer implements SerializeInterface
{
    public function serialize(array $content): string
    {
    }

    public function unserialize(string $content): array
    {
    }
}

use \Morphable\SimpleCache;

$serializer = new MySerializer();
$cache = new SimpleCache($root . '/.cache', $serializer);