sapling/eden/fs/store/SqliteLocalStore.h
Wez Furlong 0d3f197803 pass ReloadableConfig through to LocalStore
Summary:
This makes it possible to change configuration options
for the LocalStore while the server is running.

As you'll see in the next diff, our current layering makes using
the config a bit more awkward, but at least this diff doesn't
look gross :-p

This diff doesn't introduce any new functionality or configuration.

Reviewed By: strager

Differential Revision: D12949577

fbshipit-source-id: cf897ba676b9359f92865170faa42ff17329b85f
2018-11-09 11:22:03 -08:00

47 lines
1.4 KiB
C++

/*
* Copyright (c) 2018-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#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,
std::shared_ptr<ReloadableConfig> config = nullptr);
void close() override;
void clearKeySpace(KeySpace keySpace) override;
void compactKeySpace(KeySpace keySpace) override;
StoreResult get(LocalStore::KeySpace keySpace, folly::ByteRange key)
const override;
bool hasKey(LocalStore::KeySpace keySpace, folly::ByteRange key)
const override;
void put(
LocalStore::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