2012-12-18 48 views
0

我想讓Zend_Cache和兩個不同的memcached實例一起工作。兩個實例都處於活動狀態並正在偵聽,我測試了這一點,但Zend_Cache一直在memcached的默認端口中填充所有內容,完全忽略了第二個實例。這是我在我的引導代碼:帶memcached和多個實例的Zend_Cache

$backend = array(
     'name' => 'Memcached', 
     'servers' => array(array(
      'host' => '127.0.0.1', 
      'port' => '11211' 
     )), 
     'compression' => true 
    ); 

    $backend_system = array(
     'name' => 'Memcached', 
     'servers' => array(array(
      'host' => '127.0.0.1', 
      'port' => '11212' 
     )), 
     'compression' => true 
    ); 

    $systemCache = array(
      'frontend' => array(
       'name' => 'Core', 
       'options' => array(
        'lifetime' => 7*24*60*60, 
        'automatic_serialization' => true 
       ) 
      ), 
      'backend' => $backend_system 
     );    

    $dataCache = array(
      'frontend' => array(
       'name' => 'Core', 
       'options' => array(
        'lifetime' => 1*60*60, 
        'automatic_serialization' => true 
       ) 
      ), 
      'backend' => $backend 
     ); 

    $manager = new Zend_Cache_Manager; 
    $manager->setCacheTemplate('system', $systemCache); 
    $manager->setCacheTemplate('data', $dataCache); 
    Zend_Registry::set('manager' , $manager); 

這是怎麼回事錯在這裏?

回答

1

而答案很簡單:我忘了附上我的選擇在$後臺數組*數組,像這樣:

$backend_system = array(
     'name' => 'Memcached', 
     'options' => array(
      'servers' => array(array(
       'host' => '127.0.0.1', 
       'port' => '11212' 
      )), 
      'compression' => true 
     ) 
    );