Redis Error "Connection Timeout" on Caching

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

I retrieve DB objects from the collection of objects and try to save it in the cache, but I get an error: connection time checked. My sample code is:

$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); } 

The content size after serialization is 26787 bytes. Perhaps Redis has size limits for sending?

+4
source share
1 answer

If this helps, I use Rediska with ZF. This 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 ); 

The difference that I see is in the backend options. I point rediska to an instance of rediska.

0
source

Source: https://habr.com/ru/post/1395769/


All Articles