2015-04-15 15:46:35 +02:00
|
|
|
#pragma once
|
2015-04-16 14:10:44 +02:00
|
|
|
#ifndef BLOCKSTORE_IMPLEMENTATIONS_CACHING_CACHINGBLOCKSTORE_H_
|
|
|
|
#define BLOCKSTORE_IMPLEMENTATIONS_CACHING_CACHINGBLOCKSTORE_H_
|
2015-04-15 15:46:35 +02:00
|
|
|
|
2015-04-15 19:05:58 +02:00
|
|
|
#include "Cache.h"
|
2015-04-16 14:10:44 +02:00
|
|
|
#include "../../interface/BlockStore.h"
|
2015-04-15 15:46:35 +02:00
|
|
|
|
|
|
|
namespace blockstore {
|
2015-04-16 14:10:44 +02:00
|
|
|
namespace caching {
|
2015-04-15 15:46:35 +02:00
|
|
|
|
2015-04-15 20:43:21 +02:00
|
|
|
//TODO Rename this to CachingBlockStore and the other one to something else
|
2015-04-15 21:46:15 +02:00
|
|
|
//TODO Check that this blockstore allows parallel destructing of blocks (otherwise we won't encrypt blocks in parallel)
|
2015-04-16 14:10:44 +02:00
|
|
|
class CachingBlockStore: public BlockStore {
|
2015-04-15 15:46:35 +02:00
|
|
|
public:
|
2015-04-16 14:10:44 +02:00
|
|
|
CachingBlockStore(std::unique_ptr<BlockStore> baseBlockStore);
|
2015-04-15 15:46:35 +02:00
|
|
|
|
|
|
|
std::unique_ptr<Block> create(size_t size) override;
|
|
|
|
std::unique_ptr<Block> load(const Key &key) override;
|
|
|
|
void remove(std::unique_ptr<Block> block) override;
|
|
|
|
uint64_t numBlocks() const override;
|
|
|
|
|
2015-04-15 19:05:58 +02:00
|
|
|
void release(std::unique_ptr<Block> block);
|
2015-04-15 15:46:35 +02:00
|
|
|
|
2015-04-15 19:05:58 +02:00
|
|
|
private:
|
2015-04-15 15:46:35 +02:00
|
|
|
std::unique_ptr<BlockStore> _baseBlockStore;
|
2015-04-15 19:05:58 +02:00
|
|
|
Cache _cache;
|
2015-04-15 15:46:35 +02:00
|
|
|
|
2015-04-16 14:10:44 +02:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CachingBlockStore);
|
2015-04-15 15:46:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|