PHP code example of hutong / cache

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

    

hutong / cache example snippets




$config = array(
    'default' => array(
        'type' => 'File',
        'path' => '/var/www/test/cache/',
        'prefix' => '',
    ),
    'redis' => array(
        'type' => 'Redis',
    	'host' => '127.0.0.1',
    	'port' => '6379',
    	'password' => '123456',
    	'prefix' => 'web.',
    ),
);

$cache = new HuTong\Cache\Storage($config);

$val = $cache->store()->increment('getVal');
var_dump($val);
$val = $cache->store('redis')->increment('getVal');
var_dump($val);

输出:
int(1)
int(1)