Skip to content

Commit 4f48072

Browse files
committed
fixed:user memory not work
1 parent 3e59917 commit 4f48072

File tree

5 files changed

+46
-12
lines changed

5 files changed

+46
-12
lines changed

XEngine_Source/MQCore_DBModule/DBModule_Define.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,17 @@ extern "C" bool DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, __int64x nSe
282282
类型:数据结构指针
283283
可空:N
284284
意思:数据MYSQL数据库连接信息
285-
参数.二:fpCall_TimePublish
285+
参数.二:bMemoryQuery
286+
In/Out:In
287+
类型:逻辑型
288+
可空:N
289+
意思:是否启用高速缓存查询
290+
参数.三:fpCall_TimePublish
286291
In/Out:In
287292
类型:回调函数
288293
可空:N
289294
意思:定时消息发布回调函数
290-
参数.:lParam
295+
参数.:lParam
291296
In/Out:In
292297
类型:无类型指针
293298
可空:Y
@@ -297,7 +302,7 @@ extern "C" bool DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, __int64x nSe
297302
意思:是否成功
298303
备注:
299304
*********************************************************************/
300-
extern "C" bool DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam = NULL);
305+
extern "C" bool DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector, bool bMemoryQuery, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam = NULL);
301306
/********************************************************************
302307
函数名称:DBModule_MQUser_Destory
303308
函数功能:销毁数据库管理器

XEngine_Source/MQCore_DBModule/DBModule_MQUser/DBModule_MQUser.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@ CDBModule_MQUser::~CDBModule_MQUser()
3030
类型:数据结构指针
3131
可空:N
3232
意思:数据MYSQL数据库连接信息
33-
参数.二:fpCall_TimePublish
33+
参数.二:bMemoryQuery
34+
In/Out:In
35+
类型:逻辑型
36+
可空:N
37+
意思:是否启用高速缓存查询
38+
参数.三:fpCall_TimePublish
3439
In/Out:In
3540
类型:回调函数
3641
可空:N
3742
意思:定时消息发布回调函数
38-
参数.:lParam
43+
参数.:lParam
3944
In/Out:In
4045
类型:无类型指针
4146
可空:Y
@@ -45,7 +50,7 @@ CDBModule_MQUser::~CDBModule_MQUser()
4550
意思:是否成功
4651
备注:
4752
*********************************************************************/
48-
bool CDBModule_MQUser::DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam /* = NULL */)
53+
bool CDBModule_MQUser::DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector, bool bMemoryQuery, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam /* = NULL */)
4954
{
5055
DBModule_IsErrorOccur = false;
5156

@@ -64,6 +69,7 @@ bool CDBModule_MQUser::DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBCo
6469
return false;
6570
}
6671

72+
m_bMemoryQuery = bMemoryQuery;
6773
bIsRun = true;
6874
m_lParam = lParam;
6975
lpCall_TimePublish = fpCall_TimePublish;
@@ -155,6 +161,13 @@ bool CDBModule_MQUser::DBModule_MQUser_UserQuery(XENGINE_PROTOCOL_USERINFO* pSt_
155161
DBModule_dwErrorCode = ERROR_XENGINE_MQCORE_DATABASE_PARAMENT;
156162
return false;
157163
}
164+
if (m_bMemoryQuery)
165+
{
166+
if (MemoryCache_DBUser_DataQuery(pSt_UserInfo))
167+
{
168+
return true;
169+
}
170+
}
158171
//查询
159172
XNETHANDLE xhTable = 0;
160173
__int64u nllLine = 0;
@@ -206,6 +219,11 @@ bool CDBModule_MQUser::DBModule_MQUser_UserQuery(XENGINE_PROTOCOL_USERINFO* pSt_
206219
_tcsxcpy(pSt_UserInfo->tszCreateTime, pptszResult[9]);
207220
}
208221
DataBase_MySQL_FreeResult(xhDBSQL, xhTable);
222+
223+
if (m_bMemoryQuery)
224+
{
225+
MemoryCache_DBUser_DataInsert(pSt_UserInfo);
226+
}
209227
return true;
210228
}
211229
/********************************************************************
@@ -241,6 +259,10 @@ bool CDBModule_MQUser::DBModule_MQUser_UserDelete(XENGINE_PROTOCOL_USERINFO* pSt
241259
DBModule_dwErrorCode = DataBase_GetLastError();
242260
return false;
243261
}
262+
if (m_bMemoryQuery)
263+
{
264+
MemoryCache_DBUser_DataDelete(pSt_UserInfo);
265+
}
244266
return true;
245267
}
246268
/********************************************************************
@@ -284,6 +306,12 @@ bool CDBModule_MQUser::DBModule_MQUser_UserUPDate(XENGINE_PROTOCOL_USERINFO* pSt
284306
return false;
285307
}
286308

309+
if (m_bMemoryQuery)
310+
{
311+
MemoryCache_DBUser_DataDelete(pSt_UserInfo);
312+
MemoryCache_DBUser_DataInsert(pSt_UserInfo);
313+
}
314+
287315
return true;
288316
}
289317
/********************************************************************

XEngine_Source/MQCore_DBModule/DBModule_MQUser/DBModule_MQUser.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CDBModule_MQUser
1717
CDBModule_MQUser();
1818
~CDBModule_MQUser();
1919
public:
20-
bool DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam = NULL);
20+
bool DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO* pSt_DBConnector, bool bMemoryQuery, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam = NULL);
2121
bool DBModule_MQUser_Destory();
2222
bool DBModule_MQUser_UserInsert(XENGINE_PROTOCOL_USERINFO* pSt_UserInfo);
2323
bool DBModule_MQUser_UserQuery(XENGINE_PROTOCOL_USERINFO* pSt_UserInfo);
@@ -51,6 +51,7 @@ class CDBModule_MQUser
5151
XPVOID m_lParam;
5252
CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH lpCall_TimePublish;
5353
private:
54-
bool bIsRun;
55-
XNETHANDLE xhDBSQL;
54+
bool bIsRun = false;
55+
bool m_bMemoryQuery = false;
56+
XNETHANDLE xhDBSQL = 0;
5657
};

XEngine_Source/MQCore_DBModule/pch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ extern "C" bool DBModule_MQData_GetLeftCount(LPCXSTR lpszTableName, __int64x nSe
8282
/*************************************************************************
8383
消息用户导出函数
8484
**************************************************************************/
85-
extern "C" bool DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO * pSt_DBConnector, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam)
85+
extern "C" bool DBModule_MQUser_Init(DATABASE_MYSQL_CONNECTINFO * pSt_DBConnector, bool bMemoryQuery, CALLBACK_MESSAGEQUEUE_MODULE_DATABASE_TIMEPUBLISH fpCall_TimePublish, XPVOID lParam)
8686
{
87-
return m_DBUser.DBModule_MQUser_Init(pSt_DBConnector, fpCall_TimePublish, lParam);
87+
return m_DBUser.DBModule_MQUser_Init(pSt_DBConnector, bMemoryQuery, fpCall_TimePublish, lParam);
8888
}
8989
extern "C" bool DBModule_MQUser_Destory()
9090
{

XEngine_Source/XEngine_MQServiceApp/XEngine_MQServiceApp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ int main(int argc, char** argv)
208208
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化消息数据数据库失败,错误:%lX"), DBModule_GetLastError());
209209
goto NETSERVICEEXIT;
210210
}
211-
if (!DBModule_MQUser_Init((DATABASE_MYSQL_CONNECTINFO*)&st_ServiceCfg.st_XSql, MessageQueue_CBTask_TimePublish))
211+
if (!DBModule_MQUser_Init((DATABASE_MYSQL_CONNECTINFO*)&st_ServiceCfg.st_XSql, st_ServiceCfg.st_XMemory.bUserQueryEnable, MessageQueue_CBTask_TimePublish))
212212
{
213213
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化消息用户数据库失败,错误:%lX"), DBModule_GetLastError());
214214
goto NETSERVICEEXIT;

0 commit comments

Comments
 (0)