#pragma once #ifndef BLOCKSTORE_IMPLEMENTATIONS_CACHING_CACHINGBLOCKSTORE_H_ #define BLOCKSTORE_IMPLEMENTATIONS_CACHING_CACHINGBLOCKSTORE_H_ #include "Cache.h" #include "../../interface/BlockStore.h" namespace blockstore { namespace caching { //TODO Rename this to CachingBlockStore and the other one to something else //TODO Check that this blockstore allows parallel destructing of blocks (otherwise we won't encrypt blocks in parallel) class CachingBlockStore: public BlockStore { public: CachingBlockStore(std::unique_ptr baseBlockStore); Key createKey() override; std::unique_ptr tryCreate(const Key &key, Data data) override; std::unique_ptr load(const Key &key) override; void remove(std::unique_ptr block) override; uint64_t numBlocks() const override; void release(std::unique_ptr block); std::unique_ptr tryCreateInBaseStore(const Key &key, Data data); void removeFromBaseStore(std::unique_ptr block); private: std::unique_ptr _baseBlockStore; Cache _cache; uint32_t _numNewBlocks; DISALLOW_COPY_AND_ASSIGN(CachingBlockStore); }; } } #endif