]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
11fdf7f2 TL |
2 | // This source code is licensed under both the GPLv2 (found in the |
3 | // COPYING file in the root directory) and Apache 2.0 License | |
4 | // (found in the LICENSE.Apache file in the root directory). | |
7c673cae FG |
5 | #pragma once |
6 | ||
7 | #include <string> | |
8 | ||
9 | #include "monitoring/statistics.h" | |
10 | #include "table/format.h" | |
11 | #include "table/persistent_cache_options.h" | |
12 | ||
f67539c2 | 13 | namespace ROCKSDB_NAMESPACE { |
7c673cae FG |
14 | |
15 | struct BlockContents; | |
16 | ||
17 | // PersistentCacheHelper | |
18 | // | |
19 | // Encapsulates some of the helper logic for read and writing from the cache | |
20 | class PersistentCacheHelper { | |
21 | public: | |
1e59de90 TL |
22 | // Insert block into cache of serialized blocks. Size includes block trailer |
23 | // (if applicable). | |
24 | static void InsertSerialized(const PersistentCacheOptions& cache_options, | |
25 | const BlockHandle& handle, const char* data, | |
26 | const size_t size); | |
27 | ||
28 | // Insert block into cache of uncompressed blocks. No block trailer. | |
29 | static void InsertUncompressed(const PersistentCacheOptions& cache_options, | |
30 | const BlockHandle& handle, | |
31 | const BlockContents& contents); | |
32 | ||
33 | // Lookup block from cache of serialized blocks. Size includes block trailer | |
34 | // (if applicable). | |
35 | static Status LookupSerialized(const PersistentCacheOptions& cache_options, | |
36 | const BlockHandle& handle, | |
37 | std::unique_ptr<char[]>* out_data, | |
38 | const size_t expected_data_size); | |
39 | ||
40 | // Lookup block from uncompressed cache. No block trailer. | |
41 | static Status LookupUncompressed(const PersistentCacheOptions& cache_options, | |
42 | const BlockHandle& handle, | |
43 | BlockContents* contents); | |
7c673cae FG |
44 | }; |
45 | ||
f67539c2 | 46 | } // namespace ROCKSDB_NAMESPACE |