PHP code example of talesoft / tale-cache

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

    

talesoft / tale-cache example snippets


use function Tale\cache;
use function Tale\cache_pool_routing;
use function Tale\cache_pool_serialized_file;
use function Tale\cache_pool_redis; //Doesn't actually exist yet

$cache = cache(cache_pool_routing([
    'app.' => cache_pool_serialized_file(__DIR__.'/var/cache/app'),
    'db.' => cache_pool_redis('redis://localhost')
]);

$value = $cache->get('app.my_namespace.my_value');
if ($value === null) {
    $value = do_some_heavy_work()
    $cache->set('app.my_namespace.my_value', $value);
}

//$value is now cached to var/cache/app/my_namespace/my_value.cache