BlobStore also returns BlobKey
This commit is contained in:
parent
24e2d42380
commit
b64d352a8c
@ -10,9 +10,11 @@ namespace ondisk {
|
|||||||
OnDiskBlobStore::OnDiskBlobStore(const boost::filesystem::path &rootdir)
|
OnDiskBlobStore::OnDiskBlobStore(const boost::filesystem::path &rootdir)
|
||||||
: _rootdir(rootdir) {}
|
: _rootdir(rootdir) {}
|
||||||
|
|
||||||
unique_ptr<Blob> OnDiskBlobStore::create(const std::string &key, size_t size) {
|
BlobStore::BlobWithKey OnDiskBlobStore::create(const std::string &key, size_t size) {
|
||||||
auto file_path = _rootdir / key;
|
auto file_path = _rootdir / key;
|
||||||
return OnDiskBlob::CreateOnDisk(file_path, size);
|
auto blob = OnDiskBlob::CreateOnDisk(file_path, size);
|
||||||
|
|
||||||
|
return BlobStore::BlobWithKey(key, std::move(blob));
|
||||||
}
|
}
|
||||||
|
|
||||||
unique_ptr<Blob> OnDiskBlobStore::load(const std::string &key) {
|
unique_ptr<Blob> OnDiskBlobStore::load(const std::string &key) {
|
||||||
|
@ -16,7 +16,7 @@ class OnDiskBlobStore: public BlobStore {
|
|||||||
public:
|
public:
|
||||||
OnDiskBlobStore(const boost::filesystem::path &rootdir);
|
OnDiskBlobStore(const boost::filesystem::path &rootdir);
|
||||||
|
|
||||||
std::unique_ptr<Blob> create(const std::string &key, size_t size) override;
|
BlobWithKey create(const std::string &key, size_t size) override;
|
||||||
std::unique_ptr<Blob> load(const std::string &key) override;
|
std::unique_ptr<Blob> load(const std::string &key) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -5,8 +5,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "Blob.h"
|
||||||
|
|
||||||
namespace blobstore {
|
namespace blobstore {
|
||||||
class Blob;
|
|
||||||
|
|
||||||
//TODO Don't use string, but own class for keys? (better performance for all keys have same length)
|
//TODO Don't use string, but own class for keys? (better performance for all keys have same length)
|
||||||
|
|
||||||
@ -14,7 +15,14 @@ class BlobStore {
|
|||||||
public:
|
public:
|
||||||
virtual ~BlobStore() {}
|
virtual ~BlobStore() {}
|
||||||
|
|
||||||
virtual std::unique_ptr<Blob> create(const std::string &key, size_t size) = 0;
|
struct BlobWithKey {
|
||||||
|
BlobWithKey(const std::string &key_, std::unique_ptr<Blob> &&blob_): key(key_), blob(std::move(blob_)) {}
|
||||||
|
|
||||||
|
std::string key;
|
||||||
|
std::unique_ptr<Blob> blob;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual BlobWithKey create(const std::string &key, size_t size) = 0;
|
||||||
virtual std::unique_ptr<Blob> load(const std::string &key) = 0;
|
virtual std::unique_ptr<Blob> load(const std::string &key) = 0;
|
||||||
//TODO Needed for performance? Or is deleting loaded blobs enough?
|
//TODO Needed for performance? Or is deleting loaded blobs enough?
|
||||||
//virtual void remove(const std::string &key) = 0;
|
//virtual void remove(const std::string &key) = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user