![](/img/trans.png)
[英]Connection timed out [tcp://127.0.0.1:6379] using redis on linux server
[英]Redis error “Connection read timed out” during caching
我有Zend Framework項目,我決定使用Rediska作為Redis客戶端。 Rediska為ZF提供了緩存后端適配器 - Rediska_Zend_Cache_Backend_Redis。
我從數據庫集合中獲取並嘗試將其保存在緩存中但得到錯誤:連接讀取超時。 我的代碼示例:
$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);
}
序列化后的內容大小為26787字節。 也許Redis有發送的大小限制?
如果它有幫助,我也使用Rediska和ZF。 這是我如何設置它。
$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
);
我看到的差異在於后端選項。 我將rediska指向rediska實例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.