sapling/eden/fs/store/SqliteLocalStore.h
Chad Austin fae4229ff2 add eden gc command
Summary:
Add the beginnings of an eden gc command. Today it's equivalent to
`eden debug clear_local_caches` followed by `eden
debug_compact_local_storage`, except that it compacts each column as
they're cleared to minimize peak disk consumption.

Eventually, it will also unload in-memory inodes, flush data from the
overlay, and clear the kernel's VFS cache too.

Reviewed By: wez

Differential Revision: D9138305

fbshipit-source-id: b303a63f601014cf38ca94c9e6f7c04394159ea8
2018-08-10 11:38:20 -07:00

45 lines
1.3 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);
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