PHP code example of mantoufan / yzhancache

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

    

mantoufan / yzhancache example snippets


composer 

$yzhanCache = new YZhanCache('File'); // Default: File Engine 

$yzhanCache = new YZhanCache('File', array(
  'dir' => sys_get_temp_dir() . '/yzhancache' // Default Cache Dir
));

$yzhanCache->set($key, $val, $maxAge = null); // Unit of $maxAge is seconds
$yzhanCache->set('1', 'a', 1)->set('2', array(1, 2, 3)) // Chain call

$yzhanCache->get($key);
$yzhanCache->get('1'); // a
$yzhanCache->get('2'); // [1, 2, 3]
$yzhanCache->get('1'); // null, expires over $maxAge

$yzhanCache->has($key); // true / false

$yzhanCache->delete($key);
$yzhanCache->set('1', 'a')->delete('1'); // Chain call

$yzhanCache->clear();
$yzhanCache->clear()->set('1', 'a')->delete('1'); // Chain call