Beispiel #1
0
 protected function _loadFromDb()
 {
     // 如果是null,也存进缓存
     // 这个操作必须在fetchMulti之前做,因为fetchMulti时有可能触发statement queue的flush,从而导致影响_waitingKeys
     foreach (array_diff_key($this->_waitingKeys, $this->_pool) as $key => $null) {
         $this->_pool[$key] = null;
     }
     $rowset = $this->_adapter->fetchMulti(array_keys($this->_waitingKeys));
     foreach ($rowset as $key => $raw) {
         $this->_pool[$key] = $this->_adapter->unpack($raw, $key);
         // fetchMulti()之后_waitingKeys有可能增加更多的key,因此不能直接把_waitingKeys置空,而需要一行一行unset
         unset($this->_waitingKeys[$key]);
     }
     $this->_adapter->cacheMulti($rowset);
 }