Comments (4)
请把主要代码也贴一下吧,另外,同一个 redis 命令对象(即从 acl::redis_command 继承的子类对象不能跨线程操作),可以通过 acl::redis_client_cluster(网络连接)同一类对象用在多线程中。
from acl.
实际调用函数:
BOOL32 LoadScriptContent(const char* pchScriptContent, string& strSHA)
{
AUTOLOCK;
if (!m_pcRedis) return FALSE;
acl::string strSHA1;
const bool bResult = m_pcRedis->script_load(pchScriptContent, strSHA1);
if (!bResult)
{
OspPrintf(TRUE, FALSE, "[fail] [%s]Load Script content %s Failed!\n", FUNCTION, pchScriptContent);
return bResult;
}
}
封装构造类:
class CRedisImpl
{
public:
CRedisImpl()
{
m_bLogEnable = FALSE;
m_pcRedis = new acl::redis();
}
~CRedisImpl()
{
if (m_bLogEnable)
{
acl::log::close();
}
if (m_pcRedis->get_client() != NULL)
{
delete m_pcRedis->get_client();
}
delete m_pcRedis;
}
BOOL32 Init(const s8* pchIp, u16 wPort, const s8* pchPwd = NULL)
{
AUTOLOCK;
acl::acl_cpp_init();
s8 achAddr[30] = { 0 };
sprintf(achAddr, "%s:%d", pchIp, wPort);
acl::redis_client* pRedisClient = new acl::redis_client(achAddr);
if (pchPwd != NULL)
{
pRedisClient->set_password(pchPwd);
}
m_pcRedis->set_client(pRedisClient);
return TRUE;
}
private:
OspLock m_cLock;
acl::redis* m_pcRedis;
};
我们的程序是 初始化的时候,直接在堆上构造的acl::redis对象
然后后续的使用基本上是在同一线程里实际使用(load的时候是主线程Load)
from acl.
最好是你写一个简单而又完整的例子测测。
from acl.
自检发现,自身程序锁保护没做好,存在线程安全问题
from acl.
Related Issues (20)
- 各平台的编译支持 HOT 11
- mingw支持问题 HOT 2
- mbedtls_conf.cpp代码疑问 HOT 3
- 目前仅支持Redis集群3.0模式吗? HOT 1
- MYSQL
- MYSQL冲突 HOT 3
- wizard模版中setup.sh文件获取Linux x86_64等类型的处理 HOT 1
- xmake 无法编译通过 HOT 1
- 在http fiber下,在handler里面使用http_request的问题。 HOT 5
- How to resolve compilation errors HOT 1
- TLS连接redis返回握手失败 HOT 5
- make buid_one error HOT 1
- httpserver如何绑定path处理类? HOT 2
- make
- make编译报错 找不到acl——
- 安装报错
- 安装报错 HOT 9
- acl::log::msg4与soci::logger::msg4冲突 HOT 3
- sourceforge上的包5年没更新啦 HOT 1
- 向导工具生成http服务项目 windows编译运行正常 linux下链接错误 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acl.