PHP code example of silmaralberti / php-cache

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

    

silmaralberti / php-cache example snippets


$serializer = new IgBinaryLib();
$redisAdapter = new RedisAdapter($redisConnectionParams);
$hash = new HashKeyLib();

$testSettings = new PhpCacheSettingsModel(
    $redisAdapter,
    $serializer,
    $hash
);

$phpCache = new PhpCache($testSettings);

$testValue = 'storedOnCacheValue';

$result = $phpCache->cacheFunction(
    function ($testValue) {
        return $testValue;
    },
    [$testValue],
    'functionExample'
);

echo $result;
// print 'storedOnCacheValue';