knot-lib/cache

View on GitHub
demo/05_get_multiple.php

Summary

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

use Psr\SimpleCache\CacheException;

use knotlib\cache\FileCache;

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

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

    $values = $cache->getMultiple([
        'my favorite artist', 'my favorite movie'
    ]);

    echo print_r($values, true) . PHP_EOL;
}
catch(CacheException $e)
{
    echo $e->getTraceAsString();
}
catch(Throwable $e)
{
    echo $e->getTraceAsString();
}