mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2024-11-29 01:33:46 +00:00
Revert "Load save and delete scripts upon connection to Redis."
This reverts commit 1aacca9e21
.
This commit is contained in:
parent
e92ee0cef0
commit
678e8c90d1
4 changed files with 2 additions and 40 deletions
|
@ -26,7 +26,6 @@
|
||||||
#include <yaml-cpp/yaml.h>
|
#include <yaml-cpp/yaml.h>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <fstream>
|
|
||||||
#include <boost/range/empty.hpp>
|
#include <boost/range/empty.hpp>
|
||||||
|
|
||||||
namespace dindb {
|
namespace dindb {
|
||||||
|
@ -95,23 +94,6 @@ namespace dindb {
|
||||||
}
|
}
|
||||||
return retval;
|
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<char>(script), std::istreambuf_iterator<char>());
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
} //unnamed namespace
|
} //unnamed namespace
|
||||||
} //namespace dindb
|
} //namespace dindb
|
||||||
|
|
||||||
|
@ -184,9 +166,6 @@ namespace dindb {
|
||||||
oss << "Error connecting to Redis: " << m_redis.connection_error();
|
oss << "Error connecting to Redis: " << m_redis.connection_error();
|
||||||
throw std::runtime_error(oss.str());
|
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() {
|
void BackendRedis::disconnect() {
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include "backends/db_backend.hpp"
|
#include "backends/db_backend.hpp"
|
||||||
#include "command.hpp"
|
#include "command.hpp"
|
||||||
#include "script.hpp"
|
|
||||||
#include "dindexer-core/searchpaths.hpp"
|
#include "dindexer-core/searchpaths.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -59,8 +58,6 @@ namespace dindb {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
redis::Command m_redis;
|
redis::Command m_redis;
|
||||||
redis::Script m_script_save;
|
|
||||||
redis::Script m_script_delete;
|
|
||||||
dincore::SearchPaths m_lua_script_paths;
|
dincore::SearchPaths m_lua_script_paths;
|
||||||
uint16_t m_database;
|
uint16_t m_database;
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,15 +18,9 @@
|
||||||
#include "script.hpp"
|
#include "script.hpp"
|
||||||
|
|
||||||
namespace redis {
|
namespace redis {
|
||||||
Script::Script() :
|
|
||||||
m_sha1(),
|
|
||||||
m_manager(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Script::Script (boost::string_ref parSha1, ScriptManager& parManager) :
|
Script::Script (boost::string_ref parSha1, ScriptManager& parManager) :
|
||||||
m_sha1(parSha1),
|
m_sha1(parSha1),
|
||||||
m_manager(&parManager)
|
m_manager(parManager)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
} //namespace redis
|
} //namespace redis
|
||||||
|
|
|
@ -23,15 +23,12 @@
|
||||||
#include "helpers/sequence_bt.hpp"
|
#include "helpers/sequence_bt.hpp"
|
||||||
#include <boost/utility/string_ref.hpp>
|
#include <boost/utility/string_ref.hpp>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <cassert>
|
|
||||||
#include <ciso646>
|
|
||||||
|
|
||||||
namespace redis {
|
namespace redis {
|
||||||
class ScriptManager;
|
class ScriptManager;
|
||||||
|
|
||||||
class Script {
|
class Script {
|
||||||
public:
|
public:
|
||||||
Script ( void );
|
|
||||||
Script ( Script&& ) = default;
|
Script ( Script&& ) = default;
|
||||||
Script ( boost::string_ref parSha1, ScriptManager& parManager );
|
Script ( boost::string_ref parSha1, ScriptManager& parManager );
|
||||||
~Script ( void ) noexcept = default;
|
~Script ( void ) noexcept = default;
|
||||||
|
@ -39,14 +36,12 @@ namespace redis {
|
||||||
template <typename... Keys, typename... Values>
|
template <typename... Keys, typename... Values>
|
||||||
void run ( Batch& parBatch, const std::tuple<Keys...>& parKeys, const std::tuple<Values...>& parValues );
|
void run ( Batch& parBatch, const std::tuple<Keys...>& parKeys, const std::tuple<Values...>& parValues );
|
||||||
|
|
||||||
Script& operator= ( Script&& ) = default;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename... Keys, typename... Values, std::size_t... KeyIndices, std::size_t... ValueIndices>
|
template <typename... Keys, typename... Values, std::size_t... KeyIndices, std::size_t... ValueIndices>
|
||||||
void run_with_indices ( Batch& parBatch, const std::tuple<Keys...>& parKeys, const std::tuple<Values...>& parValues, dinhelp::bt::index_seq<KeyIndices...>, dinhelp::bt::index_seq<ValueIndices...> );
|
void run_with_indices ( Batch& parBatch, const std::tuple<Keys...>& parKeys, const std::tuple<Values...>& parValues, dinhelp::bt::index_seq<KeyIndices...>, dinhelp::bt::index_seq<ValueIndices...> );
|
||||||
|
|
||||||
boost::string_ref m_sha1;
|
boost::string_ref m_sha1;
|
||||||
ScriptManager* m_manager;
|
ScriptManager& m_manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Keys, typename... Values>
|
template <typename... Keys, typename... Values>
|
||||||
|
@ -67,9 +62,6 @@ namespace redis {
|
||||||
static_assert(sizeof...(Keys) == std::tuple_size<decltype(parKeys)>::value, "Wrong key count");
|
static_assert(sizeof...(Keys) == std::tuple_size<decltype(parKeys)>::value, "Wrong key count");
|
||||||
static_assert(sizeof...(Values) == std::tuple_size<decltype(parValues)>::value, "Wrong value count");
|
static_assert(sizeof...(Values) == std::tuple_size<decltype(parValues)>::value, "Wrong value count");
|
||||||
|
|
||||||
assert(not m_sha1.empty());
|
|
||||||
assert(m_manager);
|
|
||||||
|
|
||||||
parBatch.run(
|
parBatch.run(
|
||||||
"EVALSHA",
|
"EVALSHA",
|
||||||
m_sha1,
|
m_sha1,
|
||||||
|
|
Loading…
Reference in a new issue