PHP code example of lavoiesl / doctrine-cache-detector

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

    

lavoiesl / doctrine-cache-detector example snippets



use Lavoiesl\Doctrine\CacheDetector\CacheDetector;

$cache_detector = new CacheDetector;
$detectors = $cache_detector->getSupportedDetectors();

/**
 * [Apc, Filesystem, PhpFile, etc.]
 */
print_r(array_keys($detectors));

// Doctrine\Common\Cache\ApcCache
$cache = $detectors['Apc']->getCache();


$cache_detector->setConfig('Redis', array('port' => 1234));

// or

$cache_detector->setConfigs(array(
    'Redis' => array('port' => 1234),
));


use Lavoiesl\Doctrine\CacheDetector\Detector\AbstractDetector;

$array_cache    = $cache_detector->selectBest(AbstractDetector::PERSISTANCE_REQUEST)->getCache();
$apc_cache      = $cache_detector->selectBest(AbstractDetector::PERSISTANCE_LOCAL_SERVICE)->getCache();
$file_cache     = $cache_detector->selectBest(AbstractDetector::PERSISTANCE_LOCAL_PERMANENT)->getCache();
$memcache_cache = $cache_detector->selectBest(AbstractDetector::PERSISTANCE_DISTRIBUTED)->getCache();