MCPcopy Create free account
hub / github.com/cinience/RedisStudio / BackgroundWorkForRefreshKeys

Method BackgroundWorkForRefreshKeys

RedisStudio/RedisDataUI.cpp:650–745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

648}
649
650void RedisDataUI::BackgroundWorkForRefreshKeys(void)
651{
652 DBClient* cli = Env()->GetDBClient();
653 if (!cli || !cli->IsConnected()) return ;
654
655 CTreeNodeUI* pParentNode = m_pRootNode;
656 while (pParentNode->GetCountChild() != m_oObjPool.size())
657 {
658 Base::Thread::sleep(100);
659 }
660
661 for (int nodeIdx=0; nodeIdx<pParentNode->GetCountChild(); ++nodeIdx)
662 {
663 std::string sep = ":";
664 std::size_t sepIdx = 0;
665 std::map<std::string, int> sepMap;
666 sepMap[":"] = 1;
667 sepMap["/"] = 0;
668 sepMap["|"] = 0;
669 sepMap["."] = 0;
670 sepMap["-"] = 0;
671
672 CTreeNodeUI *pKeyNode = (CTreeNodeUI*) pParentNode->GetChildNode(nodeIdx);
673
674 if (m_setUpdateDbs.find(nodeIdx) == m_setUpdateDbs.end()) continue;
675
676 DelChildNode(pKeyNode);
677
678 if (!cli->SelectDB(nodeIdx)) continue;
679 /// 重新填充dbsize
680 long long dbsize = cli->DbSize();
681 CDuiString theIndex;
682 theIndex.Format(_T("%d (%lld)"), nodeIdx, dbsize);
683 CDuiString newTitle = pParentNode->GetItemText();
684 newTitle.Replace(_T("$"), theIndex.GetData());
685 pKeyNode->SetItemText(newTitle);
686
687 RedisClient::TSeqArrayResults results;
688
689 if (!cli->keys("*", results)) return;
690
691
692 /// 自动探测分割字符
693 RedisClient::TSeqArrayResults::const_iterator it = results.begin();
694 RedisClient::TSeqArrayResults::const_iterator itend = results.end();
695
696 for (it = results.begin(); it != itend && sepIdx < 10; ++it, ++sepIdx) {
697 std::string theValue = *it;
698 std::map<std::string, int>::iterator sepit = sepMap.begin();
699 std::map<std::string, int>::iterator sepitend = sepMap.end();
700 for (; sepit != sepitend; ++sepit) {
701 if (theValue.find(sepit->first) != theValue.npos) {
702 sepit->second++;
703 }
704 }
705 }
706 vector< std::pair<string, int> > vec;
707 std::map<std::string, int>::const_iterator sepit = sepMap.begin();

Callers

nothing calls this directly

Calls 14

GetDBClientMethod · 0.80
GetCountChildMethod · 0.80
GetChildNodeMethod · 0.80
FormatMethod · 0.80
ReplaceMethod · 0.80
SetItemTextMethod · 0.80
IsConnectedMethod · 0.45
sizeMethod · 0.45
SelectDBMethod · 0.45
DbSizeMethod · 0.45
GetItemTextMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected