PHP code example of ryunosuke / simple-cache

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

    

ryunosuke / simple-cache example snippets


$cache = new \ryunosuke\SimpleCache\StreamCache('s3://bucket-name/savedir');
// あるなら取得、なかったら設定しつつ取得
$cache['cache-key'] ??= heavy_function();
// つまり下記と同義です
if (!$cache->has(['cache-key'])) {
    $cache->set('cache-key', heavy_function());
}