This is a simple Key-Value store PHP class for a simple purposes such as caching.
- Notes: Not aimed to use for a simultaneous massive access. This is a wrapper class of symfony/cache component.
composer require keinos/mastodon-streaming-api-cache
<?php
namespace KEINOS\Sample;
require_once __DIR__ . '/../vendor/autoload.php';
// Instantiate
use KEINOS\MSTDN_TOOLS\Cache\Cache;
$cache = new Cache();
// Set value to the cache
$key = 'foo';
$value = 'bar';
$cache->set($key, $value);
// Get value from the cache
$actual = $cache->get($key);
$expect = $value;
echo ($expect === $actual) ? 'OK' : 'NG', PHP_EOL;
// Delete value from the cache
$result = $cache->delete($key);
// Clear all the caches
$result = $cache->clear();