PHP code example of robinn / cache

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

    

robinn / cache example snippets


$cache = new RobiNN\Cache\Cache([
    // Available config options
    'storage'   => 'file', // apcu|file|memcached|redis
    'file'      => [
        'path' => __DIR__.'/cache', // The path to the folder containing the cached content.
        //'secret' => 'secret_key', // For securing file names (optional).
        //'remove_expired' => true, // Automatically remove all expired keys (it can affect performance) (optional).
    ],
    'redis'     => [
        'host' => '127.0.0.1', // Optional when a path is specified.
        'port' => 6379, // Optional when the default port is used.
        //'database' => 0, // Default database (optional).
        //'username' => '', // ACL - o be shortened to one line
$data = $cache->remember($key, 'item-value');

print_r($data); // item-value