Friday, April 11, 2014

CakePHP with Redis not working

I am switching from Memcached to Redis as memcached does not allow me to store larger data.


When I changed my settings in core file for _cake_core_ && _cake_model_ I get the below error while running shell command


PHP Fatal error:  Uncaught exception 'CacheException' with message 'Cache engine _cake_core_ is not properly configured.' in /var/www/vhosts/analytics/lib/Cake/Cache/Cache.php:181

Stack trace:

#0 /var/www/vhosts/analytics/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine('_cake_core_')

#1 /var/www/vhosts/analytics/app/Config/core.php(279): Cache::config('_cake_core_', Array)

#2 /var/www/vhosts/analytics/lib/Cake/Core/Configure.php(72): include('/var/www/vhosts...')

#3 /var/www/vhosts/analytics/lib/Cake/bootstrap.php(175): Configure::bootstrap(true)

#4 /var/www/vhosts/analytics/lib/Cake/Console/ShellDispatcher.php(136): require('/var/www/vhosts...')

#5 /var/www/vhosts/analytics/lib/Cake/Console/ShellDispatcher.php(98): ShellDispatcher->_bootstrap()

#6 /var/www/vhosts/analytics/lib/Cake/Console/ShellDispatcher.php(54): ShellDispatcher->_initEnvironment()

#7 /var/www/vhosts/analytics/lib/Cake/Console/ShellDispatcher.php(65): ShellDispatcher->__construct(Array)

#8 /var/www/vhosts/analytics/app/Console/cake.php(33): ShellDispatche in /var/www/vhosts/analytics/lib/Cake/Cache/Cache.php on line 181


This is my code in core.php


$engine = 'Redis';

// In development mode, caches should expire quickly.

$duration = '+999 days';

if (Configure::read('debug') >= 1) {

$duration = '+0 seconds';

}


$duration = '+0 seconds';

$prefix = 'app_';

/**

 * Configure the cache used for general framework caching.  Path information,

 * object listings, and translation cache files are stored with this configuration.

 */

Cache::config('_cake_core_', array(

'engine' => $engine,

'prefix' => $prefix . 'cake_core_',

'duration' => $duration

));


/**

 * Configure the cache for model and datasource caches.  This cache configuration

 * is used to store schema descriptions, and table listings in connections.

 */

Cache::config('_cake_model_', array(

'engine' => $engine,

'prefix' => $prefix . 'cake_model_',

'duration' => $duration

));


I also have the below in bootstrap.php and it works fine with Redis

$engine = 'Redis';

Cache::config('default', array(

    'engine' => $engine,

    'prefix' => $prefix,

    'timeout' => 100

));

Cache::config('masterreport', array(

    'engine' => $engine,

    'prefix' => '', 

    'duration' => '+0 seconds',//'+29 days',

    'timeout' => 100

));

Not sure whats happening but it throws the above stack trace while running shell 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: