PHP code example of thruster / data-cacher

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

    

thruster / data-cacher example snippets


$someCacher = new class extends BaseDataCacher
{
    public static function getName() : string
    {
        return 'some_cacher';
    }
    
    public function getKey($keyData) : array
    {
        return ['some', $keyData];
    }
    
    public function getTTL() : int
    {
        return 60 * 60 * 24 * 7
    }
};

$dataCacher = new DataCacher($driver, $someCacher);

$dataCacher->cache($object->getId(), $object);
$dataCacher->get(101);