diff --git a/Light/src/Database/Cache.cpp b/Light/src/Database/Cache.cpp index 4dc9a13..730832b 100644 --- a/Light/src/Database/Cache.cpp +++ b/Light/src/Database/Cache.cpp @@ -50,7 +50,7 @@ void Cache::disconnect() { if (context_) { redisFree(context_); context_ = nullptr; - std::cout << "Disconnected from Redis." << std::endl; + Logger::log("Disconnected from Redis.", "INFO"); } } @@ -69,8 +69,8 @@ void Cache::set(const std::string& key, const std::string& value, int expire_sec } if (reply == nullptr) { - Logger::log("Failed to execute Redis command.", "ERROR"); - throw std::runtime_error("Failed to execute Redis command."); + Logger::log("Failed to execute SET command.", "ERROR"); + throw std::runtime_error("Failed to execute SET command."); } freeReplyObject(reply); @@ -85,8 +85,8 @@ std::string Cache::get(const std::string& key) { redisReply* reply = (redisReply*)redisCommand(context_, "GET %s", key.c_str()); if (reply == nullptr) { - Logger::log("Failed to execute Redis command.", "ERROR"); - throw std::runtime_error("Failed to execute Redis command."); + Logger::log("Failed to execute GET command.", "ERROR"); + throw std::runtime_error("Failed to execute GET command."); } std::string result; @@ -115,8 +115,8 @@ void Cache::del(const std::string& key) { redisReply* reply = (redisReply*)redisCommand(context_, "DEL %s", key.c_str()); if (reply == nullptr) { - Logger::log("Failed to execute Redis command.", "ERROR"); - throw std::runtime_error("Failed to execute Redis command."); + Logger::log("Failed to execute DEL command.", "ERROR"); + throw std::runtime_error("Failed to execute DEL command."); } freeReplyObject(reply); @@ -131,8 +131,8 @@ void Cache::expire(const std::string& key, int expire_seconds) { redisReply* reply = (redisReply*)redisCommand(context_, "EXPIRE %s %d", key.c_str(), expire_seconds); if (reply == nullptr) { - Logger::log("Failed to execute Redis command.", "ERROR"); - throw std::runtime_error("Failed to execute Redis command."); + Logger::log("Failed to execute EXPIRE command.", "ERROR"); + throw std::runtime_error("Failed to execute EXPIRE command."); } freeReplyObject(reply); diff --git a/Light/src/Database/Queue.cpp b/Light/src/Database/Queue.cpp index 14b626b..4939de8 100644 --- a/Light/src/Database/Queue.cpp +++ b/Light/src/Database/Queue.cpp @@ -62,8 +62,8 @@ void Queue::push(const std::string& queue_name, const std::string& value) { redisReply* reply = (redisReply*)redisCommand(context_, "RPUSH %s %s", queue_name.c_str(), value.c_str()); if (reply == nullptr) { - Logger::log("Failed to execute Redis command.", "ERROR"); - throw std::runtime_error("Failed to execute Redis command."); + Logger::log("Failed to execute RPUSH command.", "ERROR"); + throw std::runtime_error("Failed to execute RPUSH command."); } freeReplyObject(reply); @@ -78,8 +78,8 @@ std::string Queue::pop(const std::string& queue_name) { redisReply* reply = (redisReply*)redisCommand(context_, "LPOP %s", queue_name.c_str()); if (reply == nullptr) { - Logger::log("Failed to execute Redis command.", "ERROR"); - throw std::runtime_error("Failed to execute Redis command."); + Logger::log("Failed to execute LPOP command.", "ERROR"); + throw std::runtime_error("Failed to execute LPOP command."); } std::string result; @@ -108,8 +108,8 @@ int Queue::length(const std::string& queue_name) { redisReply* reply = (redisReply*)redisCommand(context_, "LLEN %s", queue_name.c_str()); if (reply == nullptr) { - Logger::log("Failed to execute Redis command.", "ERROR"); - throw std::runtime_error("Failed to execute Redis command."); + Logger::log("Failed to execute LLEN command.", "ERROR"); + throw std::runtime_error("Failed to execute LLEN command."); } int len = reply->integer;