userver: userver/cache/data_provider.hpp Source File
Loading...
Searching...
No Matches
data_provider.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/cache/data_provider.hpp
4/// @brief A simple interface for hiding implementation and making mocks easy to implement
5
6#include <userver/utils/shared_readable_ptr.hpp>
7
8USERVER_NAMESPACE_BEGIN
9
10namespace cache {
11
12/// @brief Interface for providing cached data of type T
13/// @tparam T The type of data being provided
14///
15/// DataProvider is a simple interface that allows hiding implementation
16/// details and making mocks easy to implement. It provides a way to
17/// retrieve shared readable pointers to cached data.
18
19template <typename T>
21public:
22 using DataType = T;
23
24 virtual ~DataProvider() = default;
25
26 virtual utils::SharedReadablePtr<DataType> Get() const = 0;
27};
28
29} // namespace cache
30
31USERVER_NAMESPACE_END