Пример Redis

This commit is contained in:
Andrei Astafev 2020-04-24 14:27:19 +03:00
parent ab825123f2
commit 8ff24d264c

View File

@ -13,11 +13,10 @@ class RedisClient : public QObject
MR::Request* m_request; MR::Request* m_request;
public: public:
RedisClient() RedisClient(QObject* parent = nullptr) : QObject(parent)
{ {
connect(&m_client, &MR::Client::connected, this, &RedisClient::slotConnected); connect(&m_client, &MR::Client::connected, this, &RedisClient::slotConnected);
m_client.connectToHost("127.0.0.1"); m_client.connectToHost("127.0.0.1");
} }
virtual ~RedisClient() {} virtual ~RedisClient() {}
@ -33,6 +32,9 @@ public:
qDebug() << const_cast<MR::Reply&>(reply).value().toString(); qDebug() << const_cast<MR::Reply&>(reply).value().toString();
m_request->disconnect(); m_request->disconnect();
m_request->deleteLater(); m_request->deleteLater();
m_request = m_client.sendCommand( "SET value 10" );
connect(m_request, &MR::Request::reply, this, &RedisClient::slotSetValue);
} }
@ -62,6 +64,6 @@ public:
Q_SLOT void slotSubscribeTest( const MR::Reply& reply) Q_SLOT void slotSubscribeTest( const MR::Reply& reply)
{ {
qDebug() << static_cast<int>(reply.type()); qDebug() << static_cast<int>(reply.type());
qDebug() << const_cast<MR::Reply&>(reply).value().toByteArray(); qDebug() << const_cast<MR::Reply&>(reply).value();
} }
}; };