diff options
-rw-r--r-- | src/server/server.cc | 9 | ||||
-rw-r--r-- | src/server/server.h | 1 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/server/server.cc b/src/server/server.cc index ab1db9e..2c2ff33 100644 --- a/src/server/server.cc +++ b/src/server/server.cc @@ -114,7 +114,7 @@ std::shared_ptr<p18::response_type::BaseResponse> Server::executeCommand(p18::Co auto it = cache_.find(commandType); if (it != cache_.end()) { auto cr = it->second; - if (voltronic::timestamp() - cr.time <= cacheTimeout_) { + if (voltronic::timestamp() - cr.time <= cacheTimeout_ && arguments == cr.arguments) { return cr.response; } @@ -123,7 +123,11 @@ std::shared_ptr<p18::response_type::BaseResponse> Server::executeCommand(p18::Co try { auto response = client_.execute(commandType, arguments); - CachedResponse cr{voltronic::timestamp(), response}; + CachedResponse cr { + .time = voltronic::timestamp(), + .arguments = arguments, + .response = response + }; cache_[commandType] = cr; return response; } @@ -141,5 +145,4 @@ std::shared_ptr<p18::response_type::BaseResponse> Server::executeCommand(p18::Co } } - }
\ No newline at end of file diff --git a/src/server/server.h b/src/server/server.h index 76b2a1b..e083c7e 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -28,6 +28,7 @@ class Connection; struct CachedResponse { u64 time; + std::vector<std::string> arguments; std::shared_ptr<p18::response_type::BaseResponse> response; }; |