futriix/src/storage/teststorageprovider.h
John Sully 2f46f18c35 Perf remove extra lookup in rocksdb
Former-commit-id: 8074472c7a25572a53f1166911920c2cb168c141
2019-12-23 23:32:04 -05:00

31 lines
952 B
C++

#include "../IStorage.h"
#include <string>
#include <unordered_map>
class TestStorageFactory : public IStorageFactory
{
virtual class IStorage *create(int db) override;
virtual const char *name() const override;
};
class TestStorageProvider final : public IStorage
{
std::unordered_map<std::string, std::string> m_map;
public:
TestStorageProvider();
virtual ~TestStorageProvider();
virtual void insert(const char *key, size_t cchKey, void *data, size_t cb, bool fHintOverwrite) override;
virtual bool erase(const char *key, size_t cchKey) override;
virtual void retrieve(const char *key, size_t cchKey, callbackSingle fn) const override;
virtual size_t clear() override;
virtual bool enumerate(callback fn) const override;
virtual size_t count() const override;
virtual void flush() override;
/* This is permitted to be a shallow clone */
virtual const IStorage *clone() const override;
};