PHP code example of keinos / mastodon-streaming-api-cache

1. Go to this page and download the library: Download keinos/mastodon-streaming-api-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/ */

    

keinos / mastodon-streaming-api-cache example snippets




namespace KEINOS\Sample;

_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();