input/cache: first draft of the file cache

This commit is contained in:
Max Kellermann
2019-05-08 18:39:00 +02:00
parent e8a0ce643a
commit 5d74b5cee1
27 changed files with 880 additions and 6 deletions

@@ -31,6 +31,8 @@
#include "Log.hxx"
#include "input/InputStream.hxx"
#include "input/LocalOpen.hxx"
#include "input/cache/Manager.hxx"
#include "input/cache/Stream.hxx"
#include "fs/Path.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StringBuffer.hxx"
@@ -52,8 +54,18 @@ DecoderBridge::~DecoderBridge() noexcept
}
InputStreamPtr
DecoderBridge::OpenLocal(Path path_fs)
DecoderBridge::OpenLocal(Path path_fs, const char *uri_utf8)
{
if (dc.input_cache != nullptr) {
auto lease = dc.input_cache->Get(uri_utf8, true);
if (lease) {
auto is = std::make_unique<CacheInputStream>(std::move(lease),
dc.mutex);
is->SetHandler(&dc);
return is;
}
}
return OpenLocalInputStream(path_fs, dc.mutex);
}