-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsimple_lru_cache.h
50 lines (38 loc) · 1.73 KB
/
simple_lru_cache.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// For inclusion in .h files. The real class definition is in
// simple_lru_cache_inl.h.
#ifndef GOOGLE_SERVICE_CONTROL_CLIENT_UTILS_SIMPLE_LRU_CACHE_H_
#define GOOGLE_SERVICE_CONTROL_CLIENT_UTILS_SIMPLE_LRU_CACHE_H_
#include <functional>
#include <unordered_map> // for hash<>
namespace google {
namespace service_control_client {
namespace internal {
template <typename T>
struct SimpleLRUHash : public std::hash<T> {};
} // namespace internal
template <typename Key, typename Value,
typename H = internal::SimpleLRUHash<Key>,
typename EQ = std::equal_to<Key> >
class SimpleLRUCache;
// Deleter is a functor that defines how to delete a Value*. That is, it
// contains a public method:
// operator() (Value* value)
// See example in the associated unittest.
template <typename Key, typename Value, typename Deleter,
typename H = internal::SimpleLRUHash<Key>,
typename EQ = std::equal_to<Key> >
class SimpleLRUCacheWithDeleter;
} // namespace service_control_client
} // namespace google
#endif // GOOGLE_SERVICE_CONTROL_CLIENT_UTILS_SIMPLE_LRU_CACHE_H_