PHP code example of peloncano / cakephp-plugin-redis-cache

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

    

peloncano / cakephp-plugin-redis-cache example snippets


CakePlugin::load(array('RedisCache' => array('bootstrap' => true)));

$config['RedisCache'] = array(
    'cache' => array(
        'password' => '',
        'port' => 6379,
        'database' => 0
    )
);

$config['RedisCache'] = array(
    'cache' => array(
        'scheme' => 'tls',
        'ssl' => ['verify_peer' => false], // any other predis SSL related options here
        'host' => 'localhost',
        'password' => '',
        'port' => 6379, // could be different for tls connections
        'database' => 0
    )
);

Cache::config('default', array('engine' => 'RedisCache.Redis'));

// with prefix and duration
Cache::config('other_cache_with_prefix', array(
		'engine' => 'RedisCache.Redis', 
		'prefix' => 'other_cache_with_prefix', 
		'duration'=> '+1 week'
));
	
// `throwExceptions` set to TRUE will throw exceptions on redis connection issues
// by default this is FALSE which will allow the app to continue working if caching fails
// due to redis/predis connection issues
Cache::config('other_cache', array(
		'engine' => 'RedisCache.Redis', 
		'throwExceptions' => true
));

Configure::write('Session', array(
        'cookie' => {{YOUR COOKIE NAME HERE}}
        , 'timeout' => 60
        , 'handler' => array(
            'engine' => 'RedisCache.RedisSession'
        )
	));