4

I have Zend Framework project and I decided to use Rediska as Redis client. Rediska has cache backend adapter for ZF - Rediska_Zend_Cache_Backend_Redis.

I fetch from DB collection of objects and try to save it in cache but get error: Connection read timed out. My example of code:

$rediskaOptions = array(
                    'name' => 'cache',
                    'namespace' => 'Cache_',
                    'servers' => array( 'cache' => array(
                        'host'   => Rediska_Connection::DEFAULT_HOST,
                        'port'   => Rediska_Connection::DEFAULT_PORT,
                        'password' => 'qwerty'
                        )
                    )
        );

$cache = Zend_Cache::factory('Core', 'Rediska_Zend_Cache_Backend_Redis',
  array('lifetime' => NULL, 'automatic_serialization' => true),
  array('rediska' => $rediskaOptions), false, true
);
$cacheId = 'news_main';
if (!($topics = $cache->load($cacheId))) {
    $topics = DAOFactory::getInstance()->getTopicDAO()->fetchTopic(1);
    $cache->save($topics, $cacheId);
}

Size of content after serialization is 26787 bytes. Maybe Redis have size limitations for sending?

Dmitro
  • 1,489
  • 4
  • 22
  • 40
  • Redis size limitations on values are much higher than this. The theoretical limit for a string value is 512MB. It should have no problem to store 26KB objects. – Didier Spezia Feb 11 '12 at 09:59
  • What is the value of the readTimeout parameter? http://rediska.geometria-lab.net/documentation/configuration/servers/ – Didier Spezia Feb 11 '12 at 10:11
  • i set timeout 0 in /etc/redis/redis.conf and readTimeout in rediska has default value - null. – Dmitro Feb 11 '12 at 14:29

1 Answers1

0

If it helps, I am using Rediska with ZF as well. Here is how I set it up.

$options = array(
                'servers' => array(
                    array(  'host'     => '127.0.0.1',
                            'port'     => 6379,
                            'alias'    => 'cache'
                ),
                //'name' => 'cache',
                //'namespace' => 'Cache_'
                )
            );

    $rediska = new Rediska($options);

    $frontendOptions = array('automatic_serialization' => true);
    $backendOptions  = array('rediska' => $rediska);

    $cache = Zend_Cache::factory( 'Core',
            'Rediska_Zend_Cache_Backend_Redis',
            $frontendOptions,
            $backendOptions,
            false,
            true
    );

A difference I see is in the backend options. I point rediska to a rediska instance.

Matthew Scragg
  • 4,540
  • 3
  • 19
  • 27