Beispiel #1
0
 /**
  * Initialize the Redis Cache Engine
  *
  * Called automatically by the cache frontend
  * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
  *
  * @param array $settings array of setting for the engine
  * @return boolean true
  */
 public function init($settings = array())
 {
     $this->settings = array_merge(array('engine' => 'Redis', 'prefix' => Inflector::slug(basename(dirname(dirname(APP)))) . '_'), $settings, RedisCache::settings('cache'));
     parent::init($this->settings);
     if (!isset($this->redis)) {
         $this->redis = new Redis();
         $this->redis->pconnect($this->settings['hostname'], $this->settings['port']);
         if (defined('Redis::SERIALIZER_IGBINARY')) {
             $this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);
         } else {
             $this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
         }
     }
     return true;
 }
Beispiel #2
0
<?php

App::import('Lib', 'RedisCache.RedisCache');
if (!RedisCache::hasSettings('cache')) {
    RedisCache::settings('cache', array('hostname' => '127.0.0.1', 'port' => 6379, 'password' => null));
}
if (!RedisCache::hasSettings('session')) {
    RedisCache::settings('session', array('hostname' => '127.0.0.1', 'port' => 6379, 'password' => null));
}