]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/include/rocksdb/persistent_cache.h
1 // Copyright (c) 2013, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
5 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
6 // Use of this source code is governed by a BSD-style license that can be
7 // found in the LICENSE file. See the AUTHORS file for names of contributors.
14 #include "rocksdb/env.h"
15 #include "rocksdb/slice.h"
16 #include "rocksdb/statistics.h"
17 #include "rocksdb/status.h"
23 // Persistent cache interface for caching IO pages on a persistent medium. The
24 // cache interface is specifically designed for persistent read cache.
25 class PersistentCache
{
27 typedef std::vector
<std::map
<std::string
, double>> StatsType
;
29 virtual ~PersistentCache() {}
31 // Insert to page cache
33 // page_key Identifier to identify a page uniquely across restarts
35 // size Size of the page
36 virtual Status
Insert(const Slice
& key
, const char* data
,
37 const size_t size
) = 0;
39 // Lookup page cache by page identifier
41 // page_key Page identifier
42 // buf Buffer where the data should be copied
43 // size Size of the page
44 virtual Status
Lookup(const Slice
& key
, std::unique_ptr
<char[]>* data
,
47 // Is cache storing uncompressed data ?
49 // True if the cache is configured to store uncompressed data else false
50 virtual bool IsCompressed() = 0;
52 // Return stats as map of {string, double} per-tier
54 // Persistent cache can be initialized as a tier of caches. The stats are per
56 virtual StatsType
Stats() = 0;
58 virtual std::string
GetPrintableOptions() const = 0;
61 // Factor method to create a new persistent cache
62 Status
NewPersistentCache(Env
* const env
, const std::string
& path
,
64 const std::shared_ptr
<Logger
>& log
,
65 const bool optimized_for_nvm
,
66 std::shared_ptr
<PersistentCache
>* cache
);
67 } // namespace rocksdb