implemented prepared statement for postgres and sqlite

This commit is contained in:
2023-12-09 11:08:03 +01:00
parent 8ba70cc79e
commit da423ea8bb
59 changed files with 1769 additions and 314 deletions
+36
View File
@@ -0,0 +1,36 @@
#ifndef QUERY_STATEMENT_CACHE_HPP
#define QUERY_STATEMENT_CACHE_HPP
#include "matador/sql/statement.hpp"
#include <memory>
#include <mutex>
#include <string>
#include <unordered_map>
namespace matador::sql {
class connection;
struct cache_info
{
std::unique_ptr<statement> statement_;
size_t connection_id_;
};
class statement_cache
{
public:
statement& acquire(const std::string &stmt, const connection &conn);
void release(const statement &stmt);
private:
mutable std::mutex mutex_;
size_t max_cache_size_{256};
std::hash<std::string> hash_;
using statement_map = std::unordered_map<size_t, cache_info>;
statement_map statement_map_;
};
}
#endif //QUERY_STATEMENT_CACHE_HPP