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; } }
private function _vInsertInfo(&$arr, $oDao, $sHintId, $vAdmin) { $arr[$this->_sIdField] = $sHintId; if (strlen($this->_sKindField)) { $arr[$this->_sKindField] = $oDao->sGetTableName(); } if (strlen($this->_sAdminField)) { $arr[$this->_sAdminField] = is_array($vAdmin) ? Ko_Tool_Enc::SEncode($vAdmin) : $vAdmin; } if (strlen($this->_sIpField)) { $arr[$this->_sIpField] = Ko_Tool_Ip::SGetClientIP(); } $this->_oObsDao->aInsert($arr); }
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 _vSaveCache($iOid, $aInfo) { if (strlen($this->_aConf['cache']) || strlen($this->_aConf['mc'])) { $cache = Ko_Tool_Enc::SEncode($aInfo); $aData = array('oid' => $iOid, 'cache' => $cache); $aUpdate = array('cache' => $cache); } if (strlen($this->_aConf['cache'])) { $cacheDao = $this->_aConf['cache'] . 'Dao'; $this->{$cacheDao}->aInsert($aData, $aUpdate); } if (strlen($this->_aConf['mc'])) { $key = $this->_sGetMCKey($iOid); $mcDao = $this->_aConf['mc'] . 'Dao'; $this->{$mcDao}->bSet($key, $cache); } }
/** * 将在 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 iSend2Mass($msgtype, array $content, $masstag = 'all') { $ctime = date('Y-m-d H:i:s'); $content = Ko_Tool_Enc::SEncode($content); $data = compact('msgtype', 'content', 'ctime'); $contentDao = $this->_aConf['content'] . 'Dao'; $msgid = $this->{$contentDao}->iInsert($data); $masstagDao = $this->_aConf['masstag'] . 'Dao'; $masstaginfo = $this->{$masstagDao}->aGet($masstag); if (false === ($masstagmsgids = unserialize($masstaginfo['msgids']))) { $masstagmsgids = array(); } $masstagmsgids[] = $msgid; $masstagmsgids = array_slice($masstagmsgids, -5); $update = array('msgids' => serialize($masstagmsgids)); $this->{$masstagDao}->iUpdate($masstag, $update); return $msgid; }
private function _vSetExif($sDest, $exif) { unset($exif['MakerNote']); unset($exif['UserComment']); $exifDao = $this->_aConf['exif'] . 'Dao'; $data = array('dest' => $sDest, 'exif' => Ko_Tool_Enc::SEncode($exif)); $update = array('exif' => Ko_Tool_Enc::SEncode($exif)); $this->{$exifDao}->aInsert($data, $update); }