10225501448 李度 10225101546 陈胤遒 10215501422 高宇菲
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.4 KiB

  1. // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file. See the AUTHORS file for names of contributors.
  4. //
  5. // Thread-safe (provides internal synchronization)
  6. #ifndef STORAGE_LEVELDB_DB_TABLE_CACHE_H_
  7. #define STORAGE_LEVELDB_DB_TABLE_CACHE_H_
  8. #include <string>
  9. #include <stdint.h>
  10. #include "db/dbformat.h"
  11. #include "include/cache.h"
  12. #include "include/table.h"
  13. #include "port/port.h"
  14. namespace leveldb {
  15. class Env;
  16. class TableCache {
  17. public:
  18. TableCache(const std::string& dbname, const Options* options, int entries);
  19. ~TableCache();
  20. // Get an iterator for the specified file number and return it. If
  21. // "tableptr" is non-NULL, also sets "*tableptr" to point to the
  22. // Table object underlying the returned iterator, or NULL if no
  23. // Table object underlies the returned iterator. The returned
  24. // "*tableptr" object is owned by the cache and should not be
  25. // deleted, and is valid for as long as the returned iterator is
  26. // live.
  27. Iterator* NewIterator(const ReadOptions& options,
  28. uint64_t file_number,
  29. Table** tableptr = NULL);
  30. // Evict any entry for the specified file number
  31. void Evict(uint64_t file_number);
  32. private:
  33. Env* const env_;
  34. const std::string dbname_;
  35. const Options* options_;
  36. Cache* cache_;
  37. };
  38. }
  39. #endif // STORAGE_LEVELDB_DB_TABLE_CACHE_H_