sapling/eden/fs/store/MemoryLocalStore.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

42 lines
1.3 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 <folly/experimental/StringKeyedUnorderedMap.h>
#include "eden/fs/store/LocalStore.h"
namespace facebook {
namespace eden {
/** An implementation of LocalStore that stores values in memory.
* Stored values remain in memory for the lifetime of the
* MemoryLocalStore instance.
* MemoryLocalStore is thread safe, allowing concurrent reads and
* writes from any thread.
* */
class MemoryLocalStore : public LocalStore {
public:
explicit MemoryLocalStore();
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:
folly::Synchronized<std::vector<folly::StringKeyedUnorderedMap<std::string>>>
storage_;
};
} // namespace eden
} // namespace facebook