1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. 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). 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 13 namespace ROCKSDB_NAMESPACE { 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: 22 // insert block into raw page cache 23 static void InsertRawPage(const PersistentCacheOptions& cache_options, 24 const BlockHandle& handle, const char* data, 25 const size_t size); 26 27 // insert block into uncompressed cache 28 static void InsertUncompressedPage( 29 const PersistentCacheOptions& cache_options, const BlockHandle& handle, 30 const BlockContents& contents); 31 32 // lookup block from raw page cacge 33 static Status LookupRawPage(const PersistentCacheOptions& cache_options, 34 const BlockHandle& handle, 35 std::unique_ptr<char[]>* raw_data, 36 const size_t raw_data_size); 37 38 // lookup block from uncompressed cache 39 static Status LookupUncompressedPage( 40 const PersistentCacheOptions& cache_options, const BlockHandle& handle, 41 BlockContents* contents); 42 }; 43 44 } // namespace ROCKSDB_NAMESPACE 45