1. Go to this page and download the library: Download drift/react-key-value 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/ */
drift / react-key-value example snippets
use React\EventLoop\Factory;
use Drift\Cache\LocalKeyValueCache;
$loop = Factory::create();
$cache = new LocalKeyValueCache($loop);
$cache->set('my_key', 'Any value');
use React\EventLoop\Factory;
use Drift\Cache\LocalKeyValueCache;
$loop = Factory::create();
$ttl = 0.1; // Means 0.1 second (100 milliseconds)
$cache = new LocalKeyValueCache($loop);
$cache->set('my_key', 'Any value', $ttl);
use React\EventLoop\Factory;
use Drift\Cache\LocalKeyValueCache;
$loop = Factory::create();
$cache = new LocalKeyValueCache($loop);
$cache->set('my_key', 'Any value');
$value = $cache->get('my_key');
use React\EventLoop\Factory;
use Drift\Cache\LocalKeyValueCache;
$loop = Factory::create();
$cache = new LocalKeyValueCache($loop);
$ttl = 2; // Means 2 seconds
$cache->set('my_key', 'Any value');
// ... After 1 second
$value = $cache->get('my_key', true); // Found
// ... After 1 second
$value = $cache->get('my_key', true); // Found
// ... After 1 second
$value = $cache->get('my_key', true); // Found
// ... After 3 second
$value = $cache->get('my_key', true); // Not Found
use React\EventLoop\Factory;
use Drift\Cache\LocalKeyValueCache;
$loop = Factory::create();
$cache = new LocalKeyValueCache($loop);
$cache->delete('my_key');