PHP code example of yzh52521 / symfony-cache

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

    

yzh52521 / symfony-cache example snippets


composer 

namespace app\controller;

use support\Request;
use yzh52521\SymfonyCache\Cache;

class UserController
{
    public function db(Request $request)
    {
        $key = 'test_key';
        Cache::set($key, rand());
        return response(Cache::get($key));
    }
   
}

$value = Cache::store('file')->get('foo');

Cache::store('redis')->set('bar', 'baz', 600); // 10 Minutes

$value = Cache::get('key');

$value = Cache::get('key', 'default');


if (Cache::has('key')) {
    //
}

Cache::delete('key');