diff --git a/src/input/cache/Manager.cxx b/src/input/cache/Manager.cxx
index 1a798ca4c..4e8cdb318 100644
--- a/src/input/cache/Manager.cxx
+++ b/src/input/cache/Manager.cxx
@@ -58,6 +58,22 @@ InputCacheManager::~InputCacheManager() noexcept
 	items_by_time.clear_and_dispose(DeleteDisposer());
 }
 
+void
+InputCacheManager::Flush() noexcept
+{
+	items_by_time.remove_and_dispose_if([](const InputCacheItem &item){
+		return !item.IsInUse();
+	}, [this](InputCacheItem *item){
+		// TODO: eliminate code duplication, see method Remove()
+		assert(total_size >= item->size());
+		total_size -= item->size();
+		items_by_uri.erase(items_by_uri.iterator_to(*item));
+		delete item;
+	});
+
+	// TODO: invalidate busy items and flush them later
+}
+
 bool
 InputCacheManager::IsEligible(const InputStream &input) noexcept
 {
diff --git a/src/input/cache/Manager.hxx b/src/input/cache/Manager.hxx
index 4ff1b5e2f..5df58075f 100644
--- a/src/input/cache/Manager.hxx
+++ b/src/input/cache/Manager.hxx
@@ -72,6 +72,8 @@ public:
 	explicit InputCacheManager(const InputCacheConfig &config) noexcept;
 	~InputCacheManager() noexcept;
 
+	void Flush() noexcept;
+
 	gcc_pure
 	bool Contains(const char *uri) noexcept;