sapling/eden/fs/store/SqliteLocalStore.h
Chad Austin d23773e9b0 restructure KeySpace and move it into KeySpace.h
Summary: Simplify the definition and use of KeySpace and move it into its own header.

Reviewed By: simpkins

Differential Revision: D19353441

fbshipit-source-id: ef07677d927a48839b709711388abeb3c1ed9679
2020-01-21 10:33:10 -08:00

39 lines
1.1 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include <folly/Synchronized.h>
#include "eden/fs/sqlite/Sqlite.h"
#include "eden/fs/store/LocalStore.h"
namespace facebook {
namespace eden {
/** An implementation of LocalStore that stores values in Sqlite.
* SqliteLocalStore is thread safe, allowing reads and writes from
* any thread.
* */
class SqliteLocalStore : public LocalStore {
public:
explicit SqliteLocalStore(AbsolutePathPiece pathToDb);
void close() override;
void clearKeySpace(KeySpace keySpace) override;
void compactKeySpace(KeySpace keySpace) override;
StoreResult get(KeySpace keySpace, folly::ByteRange key) const override;
bool hasKey(KeySpace keySpace, folly::ByteRange key) const override;
void put(KeySpace keySpace, folly::ByteRange key, folly::ByteRange value)
override;
std::unique_ptr<LocalStore::WriteBatch> beginWrite(
size_t bufSize = 0) override;
private:
mutable SqliteDatabase db_;
};
} // namespace eden
} // namespace facebook