private function _aGet($aKey, $iExpire, $bIsObj) { try { if (empty($aKey)) { KO_DEBUG >= 4 && Ko_Tool_Debug::VAddTmpLog('data/LCache', '_aGet_Empty:' . $iExpire . ':' . ($bIsObj ? 'true' : 'false')); return array(); } $aKey = array_unique($aKey); $len = count($aKey); $tmpret = array(); for ($i = 0; $i < $len; $i += self::PROXY_ARRMAX) { KO_DEBUG >= 2 && Ko_Tool_Debug::VAddTmpLog('data/LCache', 'getAll:' . $iExpire . ':' . $len . '-' . $i); $aPara = array('keys' => array_slice($aKey, $i, self::PROXY_ARRMAX), 'expire' => intval($iExpire)); $ret = $this->_oProxy->invoke('getAll', $aPara); $tmpret = array_merge($tmpret, $ret['items']); } $ret = array(); foreach ($tmpret as $k => $v) { if (strlen($v)) { if ($bIsObj) { $o = Ko_Tool_Enc::ADecode($v); if (false !== $o) { $ret[$k] = $o; } } else { $ret[$k] = strval($v); } } } return $ret; } catch (Exception $ex) { return false; } }
public function aGetAll() { $ret = $this->mcacheDao->vGet(self::MC_ALL_MENU); if ($ret) { return Ko_Tool_Enc::ADecode($ret); } else { $oOption = new Ko_Tool_SQL(); $infos = $this->sqMenuDao->aGetList($oOption); if ($infos) { $infos = Ko_Tool_Utils::AObjs2map($infos, "id"); $this->mcacheDao->bSet(self::MC_ALL_MENU, Ko_Tool_Enc::SEncode($infos), 86400); } return $infos; } }
private function _aLoadCache($iOid) { if (strlen($this->_aConf['mc'])) { $key = $this->_sGetMCKey($iOid); $mcDao = $this->_aConf['mc'] . 'Dao'; $cache = $this->{$mcDao}->vGet($key); $info = Ko_Tool_Enc::ADecode($cache); if (!empty($info) && !empty($info['para'])) { return $info; } } if (strlen($this->_aConf['cache'])) { $cacheDao = $this->_aConf['cache'] . 'Dao'; $info = $this->{$cacheDao}->aGet($iOid); if (!empty($info)) { $info = Ko_Tool_Enc::ADecode($info['cache']); if (!empty($info) && !empty($info['para'])) { return $info; } } } return false; }
/** * 将在 cache 中的 id 过滤掉,返回不在 cache 里面的 id 列表 */ public function aFilterInCache($aId) { KO_DEBUG >= 3 && Ko_Tool_Debug::VAddTmpLog('data/DBCache', 'aFilterInCache:' . $this->_sKind . ':' . count($aId)); $this->_vCheckInProcMem(); $aKey = $this->_aConvertKeys($aId); if ($this->_iMCacheTime) { $aFilterKey = $this->_aFilterInProc($aId, $aKey, false); if (empty($aFilterKey)) { KO_DEBUG >= 1 && Ko_Tool_Debug::VAddTmpLog('stat/InProc2', count($aId) . ':0'); return array(); } $vals = $this->_oGetMCache()->vGet($aFilterKey); foreach ($vals as $k => $v) { $o = Ko_Tool_Enc::ADecode($v); if (false !== $o) { self::$s_aCache[$k] = $o; } } KO_DEBUG >= 1 && Ko_Tool_Debug::VAddTmpLog('stat/InProc2', count($aId) - count($aFilterKey) + count($vals) . ':' . count($vals)); } return $this->_aFilterInProc($aId, $aKey, true); }
private function _aGetAutoArr($sFilePath) { $templateDir = $this->_sGetTemplateDir(); $sFullname = Ko_View_Str::SGetAbsoluteFile($sFilePath, $templateDir); if (!is_file($sFullname)) { return array(); } $stime = filemtime($sFullname); $sHashFile = $this->_oSmarty->getCompileDir() . '/' . KO_VIEW_AUTOTAG . '_' . md5($sFullname); $htime = is_file($sHashFile) ? filemtime($sHashFile) : 0; if ($htime >= $stime) { $arr = Ko_Tool_Enc::ADecode(file_get_contents($sHashFile)); if (false !== $arr) { $rebuild = false; foreach ($arr[0] as $file) { $itime = is_file($file) ? filemtime($file) : time(); if ($htime < $itime) { $rebuild = true; break; } } if (!$rebuild) { return $arr[1]; } } } $aFilelist = array(); $sContent = file_get_contents($sFullname); $str = new Ko_View_Str($sContent); $aArr = $str->aParseArr($this->_oSmarty->left_delimiter, $this->_oSmarty->right_delimiter, $templateDir, $aFilelist); file_put_contents($sHashFile, Ko_Tool_Enc::SEncode(array($aFilelist, $aArr))); return $aArr; }
private function _aGet($aKey, $bIsObj) { if (is_null($this->_oMemcache)) { return false; } if (empty($aKey)) { KO_DEBUG >= 4 && Ko_Tool_Debug::VAddTmpLog('data/MemCache', '_aGet_Empty:' . ($bIsObj ? 'true' : 'false')); return array(); } $aKey = array_unique($aKey); $len = count($aKey); $tmpret = array(); for ($i = 0; $i < $len; $i += self::PROXY_ARRMAX) { KO_DEBUG >= 2 && Ko_Tool_Debug::VAddTmpLog('data/MemCache', 'getMulti:' . $len . '-' . $i); $ret = $this->_oMemcache->get(array_slice($aKey, $i, self::PROXY_ARRMAX)); if (false === $ret) { return false; } $tmpret = array_merge($tmpret, $ret); } $ret = array(); foreach ($tmpret as $k => $v) { if ($bIsObj) { $o = Ko_Tool_Enc::ADecode($v); if (false !== $o) { $ret[$k] = $o; } } else { $ret[$k] = $v; } } return $ret; }
public function aGetListSeq($uid, $kind, $boundary, $num, &$next, &$next_boundary) { $msgtypes = $this->_aKind2MsgTypes($kind); $userDao = $this->_aConf['user'] . 'Dao'; $option = new Ko_Tool_SQL(); $option->oWhere('msgtype in (?)', $msgtypes)->oOrderBy('stime desc, msgid desc')->oLimit($num + 1); list($boundary_stime, $boundary_msgid) = explode('_', $boundary); if ($boundary_msgid) { $option->oAnd('stime < ? or (stime = ? and msgid < ?)', $boundary_stime, $boundary_stime, $boundary_msgid); } $splitField = $this->{$userDao}->sGetSplitField(); if (strlen($splitField)) { $list = $this->{$userDao}->aGetList($uid, $option); } else { $option->oAnd('uid = ?', $uid); $list = $this->{$userDao}->aGetList($option); } $next = 0; if ($count = count($list)) { if (count($list) > $num) { $next = array_pop($list); $count--; $next = $next['msgid']; } } $contentDao = $this->_aConf['content'] . 'Dao'; $msginfos = $this->{$contentDao}->aGetListByKeys($list); foreach ($list as $k => &$v) { $v = array_merge($msginfos[$v['msgid']], $v); $v['content'] = Ko_Tool_Enc::ADecode($v['content']); if ($k == $count - 1) { $next_boundary = $v['stime'] . '_' . $v['msgid']; } } unset($v); return $list; }
public function aGetImageExif($sDest) { assert(strlen($this->_aConf['exif'])); $exifDao = $this->_aConf['exif'] . 'Dao'; $ret = $this->{$exifDao}->aGet($sDest); $exif = Ko_Tool_Enc::ADecode($ret['exif']); if (false === $exif) { return array(); } return $exif; }