PHP code example of viloveul / cache

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

    

viloveul / cache example snippets




$adapter = new Viloveul\Cache\ApcuAdapter();
// or
// $adapter = new Viloveul\Cache\RedisAdapter($host, $port);

$adapter->setDefaultLifeTime(3600);

$adapter->setPrefix('secret_maybe');

$cache = new Viloveul\Cache\Cache($adapter);

$cache->set('hello', 'world');

var_dump($cache->get('hello', 'default_value'));