knot-lib/cache

View on GitHub
demo/07_array_cache.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php
require_once __DIR__ . '/../vendor/autoload.php';

use Psr\SimpleCache\CacheException;

use knotlib\cache\ArrayCache;

try{
    $config = require_once(__DIR__ . '/include/config_array_cache.inc.php');
    $cache = new ArrayCache($config);

    $cache->set('my favorite artist', 'stevie wonder');

    echo 'my favorite artist: ' . $cache->get('my favorite artist') . PHP_EOL;

    sleep(6);

    echo 'my favorite artist: ' . $cache->get('my favorite artist') . PHP_EOL;
}
catch(CacheException $e)
{
    echo $e->getTraceAsString();
}
catch(Throwable $e)
{
    echo $e->getTraceAsString();
}