persistent_cache_helper.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #include <string>
  7. #include "monitoring/statistics.h"
  8. #include "table/format.h"
  9. #include "table/persistent_cache_options.h"
  10. namespace ROCKSDB_NAMESPACE {
  11. struct BlockContents;
  12. // PersistentCacheHelper
  13. //
  14. // Encapsulates some of the helper logic for read and writing from the cache
  15. class PersistentCacheHelper {
  16. public:
  17. // insert block into raw page cache
  18. static void InsertRawPage(const PersistentCacheOptions& cache_options,
  19. const BlockHandle& handle, const char* data,
  20. const size_t size);
  21. // insert block into uncompressed cache
  22. static void InsertUncompressedPage(
  23. const PersistentCacheOptions& cache_options, const BlockHandle& handle,
  24. const BlockContents& contents);
  25. // lookup block from raw page cacge
  26. static Status LookupRawPage(const PersistentCacheOptions& cache_options,
  27. const BlockHandle& handle,
  28. std::unique_ptr<char[]>* raw_data,
  29. const size_t raw_data_size);
  30. // lookup block from uncompressed cache
  31. static Status LookupUncompressedPage(
  32. const PersistentCacheOptions& cache_options, const BlockHandle& handle,
  33. BlockContents* contents);
  34. };
  35. } // namespace ROCKSDB_NAMESPACE