PHP code example of epwt / cache

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

    

epwt / cache example snippets



    $redisDriver = new EPWT\Cache\Drivers\RedisDriver();
    $redis = new Redis();
    $redis->connect('127.0.0.1');
    $redisDriver->setRedis($redis);
    
    $demoCachePool = new EPWT\Cache\Core\CacheItemPool('demo_pool');
    $demoCachePool->setDriver($redisDriver);
    
    $alternativeCachePool = new EPWT\Cache\Core\CacheItemPool('alternative_pool');
    $alternativeCachePool->setDriver($redisDriver);
    
    $cacheItemA = new EPWT\Cache\Core\CacheItem('a');
    $cacheItemA->setCacheItemPool($demoCachePool);
    $cacheItemA->set('foobar');
    
    $demoCachePool->save($cacheItemA);
    
    $a = $demoCachePool->getItem('a');
    $a->get();
    
    $alternativeCachePool->save($a);