mirror of
https://github.com/QuasarApp/Heart.git
synced 2025-05-06 06:29:43 +00:00
disable database cache by default
This commit is contained in:
parent
7349a3a3d8
commit
452e4071d4
@ -30,9 +30,21 @@ if (NOT DEFINED HEART_TESTS)
|
||||
|
||||
if (ANDROID)
|
||||
set(HEART_TESTS OFF)
|
||||
add_definitions(HEART_TESTS OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED HEART_DB_CACHE)
|
||||
set(HEART_DB_CACHE OFF)
|
||||
|
||||
if (ANDROID OR WIN32)
|
||||
set(HEART_DB_CACHE OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (HEART_DB_CACHE)
|
||||
add_definitions(-DHEART_DB_CACHE)
|
||||
endif()
|
||||
|
||||
include(QuasarAppLib/CMake/ccache.cmake)
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <isubscribabledata.h>
|
||||
#include <itoken.h>
|
||||
#include <sqlitedbcache.h>
|
||||
#include <sqldb.h>
|
||||
|
||||
#define THIS_NODE "this_node_key"
|
||||
namespace QH {
|
||||
@ -124,17 +125,17 @@ void DataBaseNode::initDefaultDbObjects(ISqlDBCache *cache,
|
||||
}
|
||||
|
||||
if (!cache) {
|
||||
cache = new SQLiteDBCache();
|
||||
cache = new SqlDB();
|
||||
}
|
||||
|
||||
cache->setWriter(writer);
|
||||
_db = cache;
|
||||
|
||||
connect(_db, &SqlDBCache::sigItemChanged,
|
||||
connect(_db, &ISqlDBCache::sigItemChanged,
|
||||
this, &DataBaseNode::handleObjectChanged,
|
||||
Qt::DirectConnection);
|
||||
|
||||
connect(_db, &SqlDBCache::sigItemDeleted,
|
||||
connect(_db, &ISqlDBCache::sigItemDeleted,
|
||||
this, &DataBaseNode::handleObjectDeleted,
|
||||
Qt::DirectConnection);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <getmaxintegerid.h>
|
||||
#include "deleteobject.h"
|
||||
#include "getsinglevalue.h"
|
||||
#include "isqldbcache.h"
|
||||
|
||||
namespace QH {
|
||||
|
||||
@ -39,7 +40,7 @@ ErrorCodes::Code SingleServer::registerNewUser(PKG::UserMember user,
|
||||
auto rawPassword = user.authenticationData();
|
||||
user.setAuthenticationData(hashgenerator(rawPassword));
|
||||
|
||||
if (!db()->insertObject(QSharedPointer<decltype(user)>::create(user))) {
|
||||
if (!db()->insertObject(QSharedPointer<decltype(user)>::create(user), true)) {
|
||||
return ErrorCodes::InternalError;
|
||||
};
|
||||
|
||||
@ -81,7 +82,7 @@ ErrorCodes::Code SingleServer::loginUser(const PKG::UserMember &user,
|
||||
|
||||
if (!localObject->getSignToken().isValid()) {
|
||||
localObject->setSignToken(generateToken(AccessToken::Year));
|
||||
if (!db()->updateObject(localObject)) {
|
||||
if (!db()->updateObject(localObject, true)) {
|
||||
return ErrorCodes::InternalError;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
* of this license document, but changing it is not allowed.
|
||||
*/
|
||||
|
||||
#ifdef HEART_DB_CACHE
|
||||
|
||||
#include "sqldbcache.h"
|
||||
#include "quasarapp.h"
|
||||
#include "sqldbwriter.h"
|
||||
@ -107,3 +109,4 @@ SqlDBCache::getFromCache(const DBObject *obj) {
|
||||
return resultType{};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -5,9 +5,12 @@
|
||||
* of this license document, but changing it is not allowed.
|
||||
*/
|
||||
|
||||
#ifdef HEART_DB_CACHE
|
||||
|
||||
#ifndef SQLDBCASHE_H
|
||||
#define SQLDBCASHE_H
|
||||
|
||||
|
||||
#include "iobjectprovider.h"
|
||||
#include "isqldbcache.h"
|
||||
|
||||
@ -48,3 +51,5 @@ private:
|
||||
|
||||
}
|
||||
#endif // SQLDBCASHE_H
|
||||
|
||||
#endif
|
||||
|
@ -5,6 +5,8 @@
|
||||
* of this license document, but changing it is not allowed.
|
||||
*/
|
||||
|
||||
#ifdef HEART_DB_CACHE
|
||||
|
||||
#include "asyncsqldbwriter.h"
|
||||
#include "sqlitedbcache.h"
|
||||
#include <QThread>
|
||||
@ -94,3 +96,5 @@ SQLiteDBCache::getFromCache(const PKG::DBObject *obj) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -5,9 +5,13 @@
|
||||
* of this license document, but changing it is not allowed.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef SQLITEDBCACHE_H
|
||||
#define SQLITEDBCACHE_H
|
||||
|
||||
#ifdef HEART_DB_CACHE
|
||||
|
||||
#include "isqldbcache.h"
|
||||
|
||||
namespace QH {
|
||||
@ -54,4 +58,6 @@ private:
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SQLITEDBCACHE_H
|
||||
|
@ -19,8 +19,10 @@
|
||||
BASE, MEMBER, CACHE, WRITER> { \
|
||||
};
|
||||
|
||||
#ifdef HEART_DB_CACHE
|
||||
TEST_CASE(Case0, QH::DataBaseNode, QH::PKG::NetworkMember, QH::SqlDBCache, QH::AsyncSqlDBWriter)
|
||||
TEST_CASE(Case1, QH::DataBaseNode, QH::PKG::NetworkMember, QH::SQLiteDBCache, QH::AsyncSqlDBWriter)
|
||||
#endif
|
||||
TEST_CASE(Case2, QH::DataBaseNode, QH::PKG::NetworkMember, QH::SqlDB, QH::AsyncSqlDBWriter)
|
||||
|
||||
|
||||
@ -37,8 +39,11 @@ void testCase(const T& t) {
|
||||
}
|
||||
|
||||
void DataBaseNodeUnitTests::test() {
|
||||
#ifdef HEART_DB_CACHE
|
||||
|
||||
RUN_TEST_CASE(Case0)
|
||||
RUN_TEST_CASE(Case1)
|
||||
#endif
|
||||
RUN_TEST_CASE(Case2)
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user