Skip to content
Snippets Groups Projects
sqlite_storage.hh 927 B
Newer Older
  • Learn to ignore specific revisions
  • Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    #ifndef __VEREIGN_KVSTORE_SQLITE_STORAGE_HH
    #define __VEREIGN_KVSTORE_SQLITE_STORAGE_HH
    
    #include <vereign/kvstore/storage.hh>
    #include <vereign/sqlite/connection.hh>
    
    namespace vereign::kvstore {
    
    class SqliteStorage : public Storage {
    public:
      SqliteStorage(const std::string& db_path);
    
      ~SqliteStorage() override;
    
      SqliteStorage(const SqliteStorage&) = delete;
      auto operator=(const SqliteStorage&) -> SqliteStorage& = delete;
    
      void Lock() override;
      void Unlock() override;
    
      void DeleteAll() override;
    
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
      void PutBytes(const std::string& key, bytes::View value) override;
      void GetBytes(const std::string& key, bytes::Buffer& value) override;
    
      void PutInt64(const std::string& key, int64_t value) override;
      auto GetInt64(const std::string& key) -> int64_t override;
    
    private:
      sqlite::Connection db_;
    
      int lock_count_ = 0;
    
    Daniel Lyubomirov's avatar
    Daniel Lyubomirov committed
    };
    
    } // namespace vereign::kvstore
    
    #endif // __VEREIGN_KVSTORE_SQLITE_STORAGE_HH