MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
ob_lru_cache.h
1/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2miniob is licensed under Mulan PSL v2.
3You can use this software according to the terms and conditions of the Mulan PSL v2.
4You may obtain a copy of Mulan PSL v2 at:
5 http://license.coscl.org.cn/MulanPSL2
6THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9See the Mulan PSL v2 for more details. */
10
11#pragma once
12
13#include <stdint.h>
14#include <cstddef>
15
16namespace oceanbase {
17
29template <typename KeyType, typename ValueType>
31{
32public:
38 ObLRUCache(size_t capacity) : capacity_(capacity) {}
39
51 bool get(const KeyType &key, ValueType &value) { return false; }
52
63 void put(const KeyType &key, const ValueType &value) {}
64
71 bool contains(const KeyType &key) const { return false; }
72
73private:
77 size_t capacity_;
78};
79
91template <typename Key, typename Value>
92ObLRUCache<Key, Value> *new_lru_cache(uint32_t capacity)
93{
94 return nullptr;
95}
96
97} // namespace oceanbase
A thread-safe implementation of an LRU (Least Recently Used) cache.
Definition: ob_lru_cache.h:31
void put(const KeyType &key, const ValueType &value)
Inserts a key-value pair into the cache.
Definition: ob_lru_cache.h:63
bool contains(const KeyType &key) const
Checks whether the specified key exists in the cache.
Definition: ob_lru_cache.h:71
bool get(const KeyType &key, ValueType &value)
Retrieves a value from the cache using the specified key.
Definition: ob_lru_cache.h:51
ObLRUCache(size_t capacity)
Constructs an ObLRUCache with a specified capacity.
Definition: ob_lru_cache.h:38
size_t capacity_
The maximum number of elements the cache can hold.
Definition: ob_lru_cache.h:77