libcryfs/implementations/caching/CachingBlockStore.cpp
2015-04-02 07:12:29 -04:00

51 lines
1.2 KiB
C++

#include <messmer/blockstore/implementations/caching/CachedBlockRef.h>
#include <messmer/blockstore/implementations/caching/CachingBlockStore.h>
#include <cassert>
using std::unique_ptr;
using std::make_unique;
using std::string;
using std::mutex;
using std::lock_guard;
using std::promise;
namespace blockstore {
namespace caching {
CachingBlockStore::CachingBlockStore(unique_ptr<BlockStore> baseBlockStore)
: _baseBlockStore(std::move(baseBlockStore)) {
}
unique_ptr<Block> CachingBlockStore::create(size_t size) {
auto block = _baseBlockStore->create(size);
return CachingStore::add(std::move(block));
}
unique_ptr<Block> CachingBlockStore::load(const Key &key) {
return CachingStore::load(key);
}
void CachingBlockStore::remove(unique_ptr<Block> block) {
return CachingStore::remove(std::move(block));
}
const Key &CachingBlockStore::getKey(const Block &block) const {
return block.key();
}
unique_ptr<Block> CachingBlockStore::loadFromBaseStore(const Key &key) {
return _baseBlockStore->load(key);
}
void CachingBlockStore::removeFromBaseStore(unique_ptr<Block> block) {
return _baseBlockStore->remove(std::move(block));
}
uint64_t CachingBlockStore::numBlocks() const {
return _baseBlockStore->numBlocks();
}
}
}