From 678e8c90d142eebc7b09d2e96f795575c8a6d239 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 8 Jul 2016 21:35:31 +0100 Subject: [PATCH] Revert "Load save and delete scripts upon connection to Redis." This reverts commit 1aacca9e21b2398ef4900a76495f301568c6fc84. --- src/backends/redis/backend_redis.cpp | 21 --------------------- src/backends/redis/backend_redis.hpp | 3 --- src/backends/redis/script.cpp | 8 +------- src/backends/redis/script.hpp | 10 +--------- 4 files changed, 2 insertions(+), 40 deletions(-) diff --git a/src/backends/redis/backend_redis.cpp b/src/backends/redis/backend_redis.cpp index 35ee375..990a6e1 100644 --- a/src/backends/redis/backend_redis.cpp +++ b/src/backends/redis/backend_redis.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include namespace dindb { @@ -95,23 +94,6 @@ namespace dindb { } return retval; } - - std::string read_script (const dincore::SearchPaths& parSearch, const char* parName) { - const auto full_path = parSearch.first_hit(boost::string_ref(parName)); - if (full_path.empty()) { - const std::string msg = std::string("Unable to locate and load Lua script \"") + parName + "\" from any of the given search paths"; - throw std::runtime_error(msg); - } - - std::ifstream script(full_path); - std::string retval; - script.seekg(0, std::ios::end); - retval.reserve(script.tellg()); - script.seekg(0, std::ios::beg); - retval.assign(std::istreambuf_iterator(script), std::istreambuf_iterator()); - - return retval; - } } //unnamed namespace } //namespace dindb @@ -184,9 +166,6 @@ namespace dindb { oss << "Error connecting to Redis: " << m_redis.connection_error(); throw std::runtime_error(oss.str()); } - - m_script_save = m_redis.make_script(read_script(m_lua_script_paths, "save.lua")); - m_script_delete = m_redis.make_script(read_script(m_lua_script_paths, "delete.lua")); } void BackendRedis::disconnect() { diff --git a/src/backends/redis/backend_redis.hpp b/src/backends/redis/backend_redis.hpp index 040a22a..d7ced97 100644 --- a/src/backends/redis/backend_redis.hpp +++ b/src/backends/redis/backend_redis.hpp @@ -20,7 +20,6 @@ #include "backends/db_backend.hpp" #include "command.hpp" -#include "script.hpp" #include "dindexer-core/searchpaths.hpp" #include #include @@ -59,8 +58,6 @@ namespace dindb { private: redis::Command m_redis; - redis::Script m_script_save; - redis::Script m_script_delete; dincore::SearchPaths m_lua_script_paths; uint16_t m_database; }; diff --git a/src/backends/redis/script.cpp b/src/backends/redis/script.cpp index d88ec39..af7eeac 100644 --- a/src/backends/redis/script.cpp +++ b/src/backends/redis/script.cpp @@ -18,15 +18,9 @@ #include "script.hpp" namespace redis { - Script::Script() : - m_sha1(), - m_manager(nullptr) - { - } - Script::Script (boost::string_ref parSha1, ScriptManager& parManager) : m_sha1(parSha1), - m_manager(&parManager) + m_manager(parManager) { } } //namespace redis diff --git a/src/backends/redis/script.hpp b/src/backends/redis/script.hpp index 033469c..e169bf6 100644 --- a/src/backends/redis/script.hpp +++ b/src/backends/redis/script.hpp @@ -23,15 +23,12 @@ #include "helpers/sequence_bt.hpp" #include #include -#include -#include namespace redis { class ScriptManager; class Script { public: - Script ( void ); Script ( Script&& ) = default; Script ( boost::string_ref parSha1, ScriptManager& parManager ); ~Script ( void ) noexcept = default; @@ -39,14 +36,12 @@ namespace redis { template void run ( Batch& parBatch, const std::tuple& parKeys, const std::tuple& parValues ); - Script& operator= ( Script&& ) = default; - private: template void run_with_indices ( Batch& parBatch, const std::tuple& parKeys, const std::tuple& parValues, dinhelp::bt::index_seq, dinhelp::bt::index_seq ); boost::string_ref m_sha1; - ScriptManager* m_manager; + ScriptManager& m_manager; }; template @@ -67,9 +62,6 @@ namespace redis { static_assert(sizeof...(Keys) == std::tuple_size::value, "Wrong key count"); static_assert(sizeof...(Values) == std::tuple_size::value, "Wrong value count"); - assert(not m_sha1.empty()); - assert(m_manager); - parBatch.run( "EVALSHA", m_sha1,