File tree Expand file tree Collapse file tree 2 files changed +18
-26
lines changed
src/app/models/key-models Expand file tree Collapse file tree 2 files changed +18
-26
lines changed Original file line number Diff line number Diff line change @@ -68,9 +68,23 @@ void StringKeyModel::addRow(const QVariantMap &row)
68
68
}
69
69
70
70
void StringKeyModel::loadRows (unsigned long , unsigned long , std::function<void (const QString&)> callback)
71
- {
72
- if (loadValue ()) {
73
- callback (QString ());
71
+ {
72
+ try {
73
+ m_connection->command ({" GET" , m_keyFullPath}, getConnector ().data (),
74
+ [this , callback](RedisClient::Response r, QString e)
75
+ {
76
+ if (r.getType () != RedisClient::Response::Bulk) {
77
+ return callback (QString (" Cannot load value" ));
78
+ }
79
+
80
+ m_rowsCache.clear ();
81
+ m_rowsCache.push_back (r.getValue ().toByteArray ());
82
+ m_notifier->dataLoaded ();
83
+
84
+ callback (QString ());
85
+ }, m_dbIndex);
86
+ } catch (const RedisClient::Connection::Exception& e) {
87
+ throw Exception (" Connection error: " + QString (e.what ()));
74
88
}
75
89
}
76
90
@@ -79,24 +93,3 @@ void StringKeyModel::removeRow(int)
79
93
m_rowCount--;
80
94
setRemovedIfEmpty ();
81
95
}
82
-
83
- bool StringKeyModel::loadValue ()
84
- {
85
- RedisClient::Response result;
86
- try {
87
- result = m_connection->commandSync ({" GET" , m_keyFullPath}, m_dbIndex);
88
- } catch (const RedisClient::Connection::Exception& e) {
89
- throw Exception (" Connection error: " + QString (e.what ()));
90
- }
91
-
92
- if (result.getType () != RedisClient::Response::Bulk) {
93
- return false ;
94
- }
95
-
96
- m_rowsCache.clear ();
97
- m_rowsCache.push_back (result.getValue ().toByteArray ());
98
-
99
- m_notifier->dataLoaded ();
100
-
101
- return true ;
102
- }
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ class StringKeyModel : public KeyModel<QByteArray>
21
21
void addLoadedRowsToCache (const QVariantList&, int ) override {}
22
22
23
23
private:
24
- enum Roles { Value = Qt::UserRole + 1 };
25
- bool loadValue ();
24
+ enum Roles { Value = Qt::UserRole + 1 };
26
25
};
27
26
You can’t perform that action at this time.
0 commit comments