-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Description
在BfdCodis.cpp中:
BfdCodis::BfdCodis(const string& zookeeperAddr, const string& proxyPath, const string& businessID)
{
m_Pool = new RoundRobinCodisPool(zookeeperAddr, proxyPath, businessID);
}
BfdCodis::~BfdCodis()
{
if (m_Pool = NULL)
{
delete m_Pool;
m_Pool = NULL;
}
}
bool BfdCodis::exists(string key, int tt)
{
return m_Pool->GetProxy()->exists(key, tt);
}
int BfdCodis::del(string key, int tt)
{
return m_Pool->GetProxy()->del(key, tt);
}
这段代码的m_Pool->GetProxy()得到的CodisClient实例,有可能会在RoundRobinCodisPool中被析构。
建议的更新方法:
- 仿照RedisClientPool.cpp的方法,GetProxy()返回的指针要从vector中pop出来
- 减少调用的层数,在RoundRobinCodisPool中维持一个Map, key是proxy地址,value是一个vector,包含这个proxy的链接池。每次轮转这个Map从中获取一个proxy,并从链接池中pop一个连接出来使用,并在使用完成后归还。
- RoundRobinCodisPool的析构要在连接池内容都被归还之后才能开始
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels